Skip to content

Commit 3ab0782

Browse files
committed
Modify integration tests that are dependent on mark.atlan.com to use a different client until they can be refactored
1 parent 1f9d9e0 commit 3ab0782

File tree

7 files changed

+221
-186
lines changed

7 files changed

+221
-186
lines changed

.github/workflows/pytest.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ jobs:
2929
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3030
- name: Test with pytest
3131
env: # Or as an environment variable
32-
ATLAN_API_KEY: ${{ secrets.MARK_ATLAN_API_KEY }}
33-
ATLAN_BASE_URL: https://mark.atlan.com
32+
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }}
33+
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }}
34+
MARK_API_KEY: ${{ secrets.MARK_ATLAN_API_KEY }}
35+
MARK_BASE_URL: https://mark.atlan.com
3436
run: |
3537
pytest

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def read(file_name):
6767
"pre-commit>=2.20.0",
6868
"deepdiff>=6.2.1",
6969
"pytest-cov>=4.0.0",
70+
"pytest-order==1.1.0",
71+
"retry==0.9.2",
7072
"twine>=4.0.2",
7173
]
7274
},

tests/integration/classification_test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright 2022 Atlan Pte. Ltd.
3-
from typing import Generator, Callable
3+
import logging
4+
from typing import Callable, Generator
45

56
import pytest
7+
from retry import retry
68

79
from pyatlan.cache.classification_cache import ClassificationCache
810
from pyatlan.client.atlan import AtlanClient
911
from pyatlan.error import AtlanError
1012
from pyatlan.model.enums import AtlanClassificationColor
1113
from pyatlan.model.typedef import ClassificationDef
1214

13-
from retry import retry
14-
import logging
15-
1615
LOGGER = logging.getLogger(__name__)
1716

1817

1918
CLS_NAME = "psdk-classification"
2019

2120

22-
@pytest.fixture(scope="session", autouse=True)
21+
@pytest.fixture(scope="module", autouse=True)
2322
def make_classification(
2423
client: AtlanClient,
2524
) -> Generator[Callable[[str], ClassificationDef], None, None]:

tests/integration/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright 2022 Atlan Pte. Ltd.
3+
import logging
34
from typing import Type
45

56
import pytest
67

78
from pyatlan.client.atlan import AtlanClient
89
from pyatlan.model.response import A
910

10-
import logging
11-
1211
LOGGER = logging.getLogger(__name__)
1312

1413

15-
@pytest.fixture(scope="session", autouse=True)
14+
@pytest.fixture(scope="module", autouse=True)
1615
def client() -> AtlanClient:
1716
return AtlanClient()
1817

tests/integration/test_client.py

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,64 @@
1212

1313

1414
@pytest.fixture(scope="module")
15-
def client() -> AtlanClient:
16-
return AtlanClient()
15+
def m_client() -> AtlanClient:
16+
from os import environ
17+
18+
client = AtlanClient(
19+
base_url=environ["MARK_BASE_URL"], api_key=environ["MARK_API_KEY"]
20+
)
21+
AtlanClient.register_client(client)
22+
return client
1723

1824

1925
@pytest.fixture(scope="module")
20-
def connection(client: AtlanClient) -> Connection:
21-
return client.get_asset_by_guid("b3a5c49a-0c7c-4e66-8453-f4da8d9ce222", Connection)
26+
def connection(m_client) -> Connection:
27+
return m_client.get_asset_by_guid(
28+
"b3a5c49a-0c7c-4e66-8453-f4da8d9ce222", Connection
29+
)
2230

2331

2432
@pytest.fixture(scope="module")
25-
def glossary(client: AtlanClient) -> Generator[AtlasGlossary, None, None]:
33+
def glossary(m_client: AtlanClient) -> Generator[AtlasGlossary, None, None]:
2634
glossary = AtlasGlossary.create(name="Integration Test Glossary")
27-
glossary = client.upsert(glossary).assets_created(asset_type=AtlasGlossary)[0]
35+
glossary = m_client.upsert(glossary).assets_created(asset_type=AtlasGlossary)[0]
2836
yield glossary
29-
client.purge_entity_by_guid(guid=glossary.guid)
37+
m_client.purge_entity_by_guid(guid=glossary.guid)
3038

3139

3240
@pytest.fixture()
3341
def database(
34-
client: AtlanClient, connection: Connection
42+
m_client: AtlanClient, connection: Connection
3543
) -> Generator[Database, None, None]:
3644
database = Database.create(
3745
name=f"Integration_Test_Entity_DB{next(iter_count)}",
3846
connection_qualified_name=connection.attributes.qualified_name,
3947
)
40-
database = client.upsert(database).assets_created(Database)[0]
48+
database = m_client.upsert(database).assets_created(Database)[0]
4149

4250
yield database
4351

44-
client.purge_entity_by_guid(guid=database.guid)
52+
m_client.purge_entity_by_guid(guid=database.guid)
4553

4654

4755
@pytest.fixture()
4856
def make_term(
49-
client: AtlanClient, glossary
57+
m_client: AtlanClient, glossary
5058
) -> Generator[Callable[[str], AtlasGlossaryTerm], None, None]:
5159
created_term_guids = []
5260

5361
def _make_term(name: str) -> AtlasGlossaryTerm:
5462
term = AtlasGlossaryTerm.create(
5563
name=f"Integration Test Glossary Term {name}", anchor=glossary
5664
)
57-
term = client.upsert(term).assets_created(AtlasGlossaryTerm)[0]
65+
term = m_client.upsert(term).assets_created(AtlasGlossaryTerm)[0]
5866
created_term_guids.append(term.guid)
5967
return term
6068

6169
yield _make_term
6270

6371
for guid in created_term_guids:
64-
client.purge_entity_by_guid(guid=guid)
72+
m_client.purge_entity_by_guid(guid=guid)
6573

6674

6775
def test_register_client_with_bad_parameter_raises_valueerror():
@@ -77,66 +85,66 @@ def test_register_client():
7785

7886

7987
def test_append_terms_with_guid(
80-
client: AtlanClient,
88+
m_client: AtlanClient,
8189
make_term: Callable[[str], AtlasGlossaryTerm],
8290
database: Database,
8391
):
8492
term = make_term("Term1")
8593

8694
assert (
87-
database := client.append_terms(
95+
database := m_client.append_terms(
8896
guid=database.guid, asset_type=Database, terms=[term]
8997
)
9098
)
91-
database = client.get_asset_by_guid(guid=database.guid, asset_type=Database)
99+
database = m_client.get_asset_by_guid(guid=database.guid, asset_type=Database)
92100
assert len(database.terms) == 1
93101
assert database.terms[0].guid == term.guid
94102

95103

96104
def test_append_terms_with_qualified_name(
97-
client: AtlanClient,
105+
m_client: AtlanClient,
98106
make_term: Callable[[str], AtlasGlossaryTerm],
99107
database: Database,
100108
):
101109
term = make_term("Term1")
102110

103111
assert (
104-
database := client.append_terms(
112+
database := m_client.append_terms(
105113
qualified_name=database.qualified_name, asset_type=Database, terms=[term]
106114
)
107115
)
108-
database = client.get_asset_by_guid(guid=database.guid, asset_type=Database)
116+
database = m_client.get_asset_by_guid(guid=database.guid, asset_type=Database)
109117
assert len(database.terms) == 1
110118
assert database.terms[0].guid == term.guid
111119

112120

113121
def test_append_terms_using_ref_by_guid_for_term(
114-
client: AtlanClient,
122+
m_client: AtlanClient,
115123
make_term: Callable[[str], AtlasGlossaryTerm],
116124
database: Database,
117125
):
118126
term = make_term("Term1")
119127

120128
assert (
121-
database := client.append_terms(
129+
database := m_client.append_terms(
122130
qualified_name=database.qualified_name,
123131
asset_type=Database,
124132
terms=[AtlasGlossaryTerm.ref_by_guid(guid=term.guid)],
125133
)
126134
)
127-
database = client.get_asset_by_guid(guid=database.guid, asset_type=Database)
135+
database = m_client.get_asset_by_guid(guid=database.guid, asset_type=Database)
128136
assert len(database.terms) == 1
129137
assert database.terms[0].guid == term.guid
130138

131139

132140
def test_replace_a_term(
133-
client: AtlanClient,
141+
m_client: AtlanClient,
134142
make_term: Callable[[str], AtlasGlossaryTerm],
135143
database: Database,
136144
):
137145
original_term = make_term("Term1")
138146
assert (
139-
database := client.append_terms(
147+
database := m_client.append_terms(
140148
qualified_name=database.qualified_name,
141149
asset_type=Database,
142150
terms=[AtlasGlossaryTerm.ref_by_guid(guid=original_term.guid)],
@@ -145,12 +153,12 @@ def test_replace_a_term(
145153

146154
replacemant_term = make_term("Term2")
147155
assert (
148-
database := client.replace_terms(
156+
database := m_client.replace_terms(
149157
guid=database.guid, asset_type=Database, terms=[replacemant_term]
150158
)
151159
)
152160

153-
database = client.get_asset_by_guid(guid=database.guid, asset_type=Database)
161+
database = m_client.get_asset_by_guid(guid=database.guid, asset_type=Database)
154162
assert len(database.terms) == 2
155163
deleted_terms = [t for t in database.terms if t.relationship_status == "DELETED"]
156164
assert len(deleted_terms) == 1
@@ -161,41 +169,41 @@ def test_replace_a_term(
161169

162170

163171
def test_replace_all_term(
164-
client: AtlanClient,
172+
m_client: AtlanClient,
165173
make_term: Callable[[str], AtlasGlossaryTerm],
166174
database: Database,
167175
):
168176
original_term = make_term("Term1")
169177
assert (
170-
database := client.append_terms(
178+
database := m_client.append_terms(
171179
qualified_name=database.qualified_name,
172180
asset_type=Database,
173181
terms=[AtlasGlossaryTerm.ref_by_guid(guid=original_term.guid)],
174182
)
175183
)
176184

177185
assert (
178-
database := client.replace_terms(
186+
database := m_client.replace_terms(
179187
guid=database.guid, asset_type=Database, terms=[]
180188
)
181189
)
182190

183-
database = client.get_asset_by_guid(guid=database.guid, asset_type=Database)
191+
database = m_client.get_asset_by_guid(guid=database.guid, asset_type=Database)
184192
assert len(database.terms) == 1
185193
deleted_terms = [t for t in database.terms if t.relationship_status == "DELETED"]
186194
assert len(deleted_terms) == 1
187195
assert deleted_terms[0].guid == original_term.guid
188196

189197

190198
def test_remove_term(
191-
client: AtlanClient,
199+
m_client: AtlanClient,
192200
make_term: Callable[[str], AtlasGlossaryTerm],
193201
database: Database,
194202
):
195203
original_term = make_term("Term1")
196204
another_term = make_term("Term2")
197205
assert (
198-
database := client.append_terms(
206+
database := m_client.append_terms(
199207
qualified_name=database.qualified_name,
200208
asset_type=Database,
201209
terms=[
@@ -206,14 +214,14 @@ def test_remove_term(
206214
)
207215

208216
assert (
209-
database := client.remove_terms(
217+
database := m_client.remove_terms(
210218
guid=database.guid,
211219
asset_type=Database,
212220
terms=[AtlasGlossaryTerm.ref_by_guid(original_term.guid)],
213221
)
214222
)
215223

216-
database = client.get_asset_by_guid(guid=database.guid, asset_type=Database)
224+
database = m_client.get_asset_by_guid(guid=database.guid, asset_type=Database)
217225
assert len(database.terms) == 2
218226
deleted_terms = [t for t in database.terms if t.relationship_status == "DELETED"]
219227
assert len(deleted_terms) == 1
@@ -222,8 +230,8 @@ def test_remove_term(
222230
assert active_terms[0].guid == another_term.guid
223231

224232

225-
def test_find_connections_by_name(client: AtlanClient):
226-
connections = client.find_connections_by_name(
233+
def test_find_connections_by_name(m_client: AtlanClient):
234+
connections = m_client.find_connections_by_name(
227235
name="Test Connection",
228236
connector_type=AtlanConnectorType.SNOWFLAKE,
229237
attributes=["connectorName"],
@@ -232,8 +240,8 @@ def test_find_connections_by_name(client: AtlanClient):
232240
assert connections[0].connector_name == AtlanConnectorType.SNOWFLAKE.value
233241

234242

235-
def test_get_lineage(client: AtlanClient):
236-
response = client.get_lineage(
243+
def test_get_lineage(m_client: AtlanClient):
244+
response = m_client.get_lineage(
237245
LineageRequest(guid="75474eab-3105-4ef9-9f84-709e386a7d3e")
238246
)
239247
for guid, asset in response.guid_entity_map.items():

0 commit comments

Comments
 (0)