12
12
13
13
14
14
@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
17
23
18
24
19
25
@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
+ )
22
30
23
31
24
32
@pytest .fixture (scope = "module" )
25
- def glossary (client : AtlanClient ) -> Generator [AtlasGlossary , None , None ]:
33
+ def glossary (m_client : AtlanClient ) -> Generator [AtlasGlossary , None , None ]:
26
34
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 ]
28
36
yield glossary
29
- client .purge_entity_by_guid (guid = glossary .guid )
37
+ m_client .purge_entity_by_guid (guid = glossary .guid )
30
38
31
39
32
40
@pytest .fixture ()
33
41
def database (
34
- client : AtlanClient , connection : Connection
42
+ m_client : AtlanClient , connection : Connection
35
43
) -> Generator [Database , None , None ]:
36
44
database = Database .create (
37
45
name = f"Integration_Test_Entity_DB{ next (iter_count )} " ,
38
46
connection_qualified_name = connection .attributes .qualified_name ,
39
47
)
40
- database = client .upsert (database ).assets_created (Database )[0 ]
48
+ database = m_client .upsert (database ).assets_created (Database )[0 ]
41
49
42
50
yield database
43
51
44
- client .purge_entity_by_guid (guid = database .guid )
52
+ m_client .purge_entity_by_guid (guid = database .guid )
45
53
46
54
47
55
@pytest .fixture ()
48
56
def make_term (
49
- client : AtlanClient , glossary
57
+ m_client : AtlanClient , glossary
50
58
) -> Generator [Callable [[str ], AtlasGlossaryTerm ], None , None ]:
51
59
created_term_guids = []
52
60
53
61
def _make_term (name : str ) -> AtlasGlossaryTerm :
54
62
term = AtlasGlossaryTerm .create (
55
63
name = f"Integration Test Glossary Term { name } " , anchor = glossary
56
64
)
57
- term = client .upsert (term ).assets_created (AtlasGlossaryTerm )[0 ]
65
+ term = m_client .upsert (term ).assets_created (AtlasGlossaryTerm )[0 ]
58
66
created_term_guids .append (term .guid )
59
67
return term
60
68
61
69
yield _make_term
62
70
63
71
for guid in created_term_guids :
64
- client .purge_entity_by_guid (guid = guid )
72
+ m_client .purge_entity_by_guid (guid = guid )
65
73
66
74
67
75
def test_register_client_with_bad_parameter_raises_valueerror ():
@@ -77,66 +85,66 @@ def test_register_client():
77
85
78
86
79
87
def test_append_terms_with_guid (
80
- client : AtlanClient ,
88
+ m_client : AtlanClient ,
81
89
make_term : Callable [[str ], AtlasGlossaryTerm ],
82
90
database : Database ,
83
91
):
84
92
term = make_term ("Term1" )
85
93
86
94
assert (
87
- database := client .append_terms (
95
+ database := m_client .append_terms (
88
96
guid = database .guid , asset_type = Database , terms = [term ]
89
97
)
90
98
)
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 )
92
100
assert len (database .terms ) == 1
93
101
assert database .terms [0 ].guid == term .guid
94
102
95
103
96
104
def test_append_terms_with_qualified_name (
97
- client : AtlanClient ,
105
+ m_client : AtlanClient ,
98
106
make_term : Callable [[str ], AtlasGlossaryTerm ],
99
107
database : Database ,
100
108
):
101
109
term = make_term ("Term1" )
102
110
103
111
assert (
104
- database := client .append_terms (
112
+ database := m_client .append_terms (
105
113
qualified_name = database .qualified_name , asset_type = Database , terms = [term ]
106
114
)
107
115
)
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 )
109
117
assert len (database .terms ) == 1
110
118
assert database .terms [0 ].guid == term .guid
111
119
112
120
113
121
def test_append_terms_using_ref_by_guid_for_term (
114
- client : AtlanClient ,
122
+ m_client : AtlanClient ,
115
123
make_term : Callable [[str ], AtlasGlossaryTerm ],
116
124
database : Database ,
117
125
):
118
126
term = make_term ("Term1" )
119
127
120
128
assert (
121
- database := client .append_terms (
129
+ database := m_client .append_terms (
122
130
qualified_name = database .qualified_name ,
123
131
asset_type = Database ,
124
132
terms = [AtlasGlossaryTerm .ref_by_guid (guid = term .guid )],
125
133
)
126
134
)
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 )
128
136
assert len (database .terms ) == 1
129
137
assert database .terms [0 ].guid == term .guid
130
138
131
139
132
140
def test_replace_a_term (
133
- client : AtlanClient ,
141
+ m_client : AtlanClient ,
134
142
make_term : Callable [[str ], AtlasGlossaryTerm ],
135
143
database : Database ,
136
144
):
137
145
original_term = make_term ("Term1" )
138
146
assert (
139
- database := client .append_terms (
147
+ database := m_client .append_terms (
140
148
qualified_name = database .qualified_name ,
141
149
asset_type = Database ,
142
150
terms = [AtlasGlossaryTerm .ref_by_guid (guid = original_term .guid )],
@@ -145,12 +153,12 @@ def test_replace_a_term(
145
153
146
154
replacemant_term = make_term ("Term2" )
147
155
assert (
148
- database := client .replace_terms (
156
+ database := m_client .replace_terms (
149
157
guid = database .guid , asset_type = Database , terms = [replacemant_term ]
150
158
)
151
159
)
152
160
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 )
154
162
assert len (database .terms ) == 2
155
163
deleted_terms = [t for t in database .terms if t .relationship_status == "DELETED" ]
156
164
assert len (deleted_terms ) == 1
@@ -161,41 +169,41 @@ def test_replace_a_term(
161
169
162
170
163
171
def test_replace_all_term (
164
- client : AtlanClient ,
172
+ m_client : AtlanClient ,
165
173
make_term : Callable [[str ], AtlasGlossaryTerm ],
166
174
database : Database ,
167
175
):
168
176
original_term = make_term ("Term1" )
169
177
assert (
170
- database := client .append_terms (
178
+ database := m_client .append_terms (
171
179
qualified_name = database .qualified_name ,
172
180
asset_type = Database ,
173
181
terms = [AtlasGlossaryTerm .ref_by_guid (guid = original_term .guid )],
174
182
)
175
183
)
176
184
177
185
assert (
178
- database := client .replace_terms (
186
+ database := m_client .replace_terms (
179
187
guid = database .guid , asset_type = Database , terms = []
180
188
)
181
189
)
182
190
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 )
184
192
assert len (database .terms ) == 1
185
193
deleted_terms = [t for t in database .terms if t .relationship_status == "DELETED" ]
186
194
assert len (deleted_terms ) == 1
187
195
assert deleted_terms [0 ].guid == original_term .guid
188
196
189
197
190
198
def test_remove_term (
191
- client : AtlanClient ,
199
+ m_client : AtlanClient ,
192
200
make_term : Callable [[str ], AtlasGlossaryTerm ],
193
201
database : Database ,
194
202
):
195
203
original_term = make_term ("Term1" )
196
204
another_term = make_term ("Term2" )
197
205
assert (
198
- database := client .append_terms (
206
+ database := m_client .append_terms (
199
207
qualified_name = database .qualified_name ,
200
208
asset_type = Database ,
201
209
terms = [
@@ -206,14 +214,14 @@ def test_remove_term(
206
214
)
207
215
208
216
assert (
209
- database := client .remove_terms (
217
+ database := m_client .remove_terms (
210
218
guid = database .guid ,
211
219
asset_type = Database ,
212
220
terms = [AtlasGlossaryTerm .ref_by_guid (original_term .guid )],
213
221
)
214
222
)
215
223
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 )
217
225
assert len (database .terms ) == 2
218
226
deleted_terms = [t for t in database .terms if t .relationship_status == "DELETED" ]
219
227
assert len (deleted_terms ) == 1
@@ -222,8 +230,8 @@ def test_remove_term(
222
230
assert active_terms [0 ].guid == another_term .guid
223
231
224
232
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 (
227
235
name = "Test Connection" ,
228
236
connector_type = AtlanConnectorType .SNOWFLAKE ,
229
237
attributes = ["connectorName" ],
@@ -232,8 +240,8 @@ def test_find_connections_by_name(client: AtlanClient):
232
240
assert connections [0 ].connector_name == AtlanConnectorType .SNOWFLAKE .value
233
241
234
242
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 (
237
245
LineageRequest (guid = "75474eab-3105-4ef9-9f84-709e386a7d3e" )
238
246
)
239
247
for guid , asset in response .guid_entity_map .items ():
0 commit comments