Skip to content

Commit 50321a7

Browse files
committed
[temp] testing
1 parent 0119e77 commit 50321a7

File tree

4 files changed

+122
-12
lines changed

4 files changed

+122
-12
lines changed

.github/workflows/pyatlan-pr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
python -m pip install --no-cache-dir --upgrade pip setuptools
6060
if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
6161
if [ -f requirements-dev.txt ]; then pip install --no-cache-dir -r requirements-dev.txt; fi
62+
pip list
6263
6364
- name: QA checks (ruff-format, ruff-lint, mypy)
6465
run: |
@@ -105,6 +106,7 @@ jobs:
105106
python -m pip install --no-cache-dir --upgrade pip setuptools
106107
if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
107108
if [ -f requirements-dev.txt ]; then pip install --no-cache-dir -r requirements-dev.txt; fi
109+
pip list
108110
109111
- name: Run integration tests
110112
env: # Test tenant environment variables

pyatlan/test_utils/base_vcr.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
"pytest-vcr plugin is not installed. Please install pytest-vcr."
1414
)
1515

16-
# Check if vcrpy is installed and ensure the version is 6.0.x
17-
try:
18-
vcr_version = pkg_resources.get_distribution("vcrpy").version
19-
if not vcr_version.startswith("6.0"):
20-
raise DependencyNotFoundError(
21-
f"vcrpy version 6.0.x is required, but found {vcr_version}. Please install the correct version."
22-
)
23-
except pkg_resources.DistributionNotFound:
24-
raise DependencyNotFoundError(
25-
"vcrpy version 6.0.x is not installed. Please install vcrpy version 6.0.x."
26-
)
16+
# # Check if vcrpy is installed and ensure the version is 6.0.x
17+
# try:
18+
# vcr_version = pkg_resources.get_distribution("vcrpy").version
19+
# if not vcr_version.startswith("6.0"):
20+
# raise DependencyNotFoundError(
21+
# f"vcrpy version 6.0.x is required, but found {vcr_version}. Please install the correct version."
22+
# )
23+
# except pkg_resources.DistributionNotFound:
24+
# raise DependencyNotFoundError(
25+
# "vcrpy version 6.0.x is not installed. Please install vcrpy version 6.0.x."
26+
# )
2727

2828
import json
2929
import os

requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ ruff~=0.9.9
33
# [PINNED] for Python 3.8 compatibility
44
# higher versions require urllib3>=2.0
55
types-requests~=2.31.0.6
6+
types-setuptools~=75.8.0.20250110
67
pytest~=8.3.4
78
pytest-vcr~=1.0.2
89
# [PINNED] to v6.x since vcrpy>=7.0 requires urllib3>=2.0
910
# which breaks compatibility with Python 3.8
10-
vcrpy~=6.0.2
11+
# vcrpy~=6.0.2
1112
pytest-order~=1.3.0
1213
pytest-timer[termcolor]~=1.0.0
1314
pytest-sugar~=1.0.0

test_vcr.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import logging
2+
from typing import Callable, List, Optional
3+
4+
import pytest
5+
import requests
6+
7+
from pyatlan.client.atlan import AtlanClient
8+
from pyatlan.model.assets import Asset, Connection
9+
from pyatlan.model.enums import AtlanConnectorType
10+
from pyatlan.model.response import AssetMutationResponse
11+
from pyatlan.test_utils import TestId
12+
from pyatlan.test_utils.base_vcr import BaseVCR
13+
14+
LOGGER = logging.getLogger(__name__)
15+
16+
17+
class TestBaseVCR(BaseVCR):
18+
@pytest.mark.vcr()
19+
def test_sample_get(self):
20+
response = requests.get("https://www.google.com/")
21+
assert response.status_code == 201
22+
23+
24+
class TestConnection(BaseVCR):
25+
connection: Optional[Connection] = None
26+
27+
@pytest.fixture(scope="module")
28+
def client(self) -> AtlanClient:
29+
return AtlanClient()
30+
31+
@pytest.fixture(scope="module")
32+
def upsert(self, client: AtlanClient):
33+
guids: List[str] = []
34+
35+
def _upsert(asset: Asset) -> AssetMutationResponse:
36+
_response = client.asset.save(asset)
37+
if (
38+
_response
39+
and _response.mutated_entities
40+
and _response.mutated_entities.CREATE
41+
):
42+
guids.append(_response.mutated_entities.CREATE[0].guid)
43+
return _response
44+
45+
yield _upsert
46+
47+
# for guid in reversed(guids):
48+
# response = client.asset.purge_by_guid(guid)
49+
# if (
50+
# not response
51+
# or not response.mutated_entities
52+
# or not response.mutated_entities.DELETE
53+
# ):
54+
# LOGGER.error(f"Failed to remove asset with GUID {guid}.")
55+
56+
@pytest.mark.vcr(cassette_name="TestConnectionCreate.json")
57+
def test_create(
58+
self,
59+
client: AtlanClient,
60+
upsert: Callable[[Asset], AssetMutationResponse],
61+
):
62+
role = client.role_cache.get_id_for_name("$admin")
63+
assert role
64+
connection_name = TestId.make_unique("INT")
65+
c = Connection.create(
66+
name=connection_name,
67+
connector_type=AtlanConnectorType.SNOWFLAKE,
68+
admin_roles=[role],
69+
)
70+
assert c.guid
71+
response = upsert(c)
72+
assert response.mutated_entities
73+
assert response.mutated_entities.CREATE
74+
assert len(response.mutated_entities.CREATE) == 1
75+
assert isinstance(response.mutated_entities.CREATE[0], Connection)
76+
assert response.guid_assignments
77+
c = response.mutated_entities.CREATE[0]
78+
c = client.asset.get_by_guid(c.guid, Connection, ignore_relationships=False)
79+
assert isinstance(c, Connection)
80+
TestConnection.connection = c
81+
82+
# @pytest.mark.order(after="test_create")
83+
# @pytest.mark.vcr()
84+
# def test_create_for_modification(
85+
# self, client: AtlanClient, upsert: Callable[[Asset], AssetMutationResponse]
86+
# ):
87+
# assert TestConnection.connection
88+
# assert TestConnection.connection.name
89+
# connection = TestConnection.connection
90+
# description = f"{connection.description} more stuff"
91+
# connection = Connection.create_for_modification(
92+
# qualified_name=TestConnection.connection.qualified_name or "",
93+
# name=TestConnection.connection.name,
94+
# )
95+
# connection.description = description
96+
# response = upsert(connection)
97+
# verify_asset_updated(response, Connection)
98+
99+
# @pytest.mark.order(after="test_create")
100+
# @pytest.mark.vcr()
101+
# def test_trim_to_required(
102+
# self, client: AtlanClient, upsert: Callable[[Asset], AssetMutationResponse]
103+
# ):
104+
# assert TestConnection.connection
105+
# connection = TestConnection.connection.trim_to_required()
106+
# response = upsert(connection)
107+
# assert response.mutated_entities is None

0 commit comments

Comments
 (0)