Skip to content

Commit 5470a5d

Browse files
committed
[chore] Sync legacy tests with main - do not revert
Legacy tests under tests/ are kept in sync with main branch. V9-specific tests live under tests_v9/. Made-with: Cursor
1 parent 9f7da90 commit 5470a5d

24 files changed

Lines changed: 199 additions & 224 deletions

tests/unit/aio/test_audit_search.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,23 @@ def load_json(filename):
4747
async def _assert_audit_search_results(
4848
results: AsyncAuditSearchResults, response_json, sorts, bulk=False
4949
):
50-
first = response_json["entityAudits"][0]
5150
async for audit in results:
52-
assert audit.entity_id == first["entityId"]
53-
assert audit.entity_qualified_name == first["entityQualifiedName"]
54-
assert audit.type_name == first["typeName"]
51+
assert audit.entity_id == response_json["entityAudits"][0]["entity_id"]
52+
assert (
53+
audit.entity_qualified_name
54+
== response_json["entityAudits"][0]["entity_qualified_name"]
55+
)
56+
assert audit.type_name == response_json["entityAudits"][0]["type_name"]
5557
expected_timestamp = datetime.fromtimestamp(
56-
first["timestamp"] / 1000, tz=timezone.utc
58+
response_json["entityAudits"][0]["timestamp"] / 1000, tz=timezone.utc
5759
)
5860
assert audit.timestamp == expected_timestamp
5961
expected_created = datetime.fromtimestamp(
60-
first["created"] / 1000, tz=timezone.utc
62+
response_json["entityAudits"][0]["created"] / 1000, tz=timezone.utc
6163
)
6264
assert audit.created == expected_created
63-
assert audit.user == first["user"]
64-
assert audit.action == first["action"]
65+
assert audit.user == response_json["entityAudits"][0]["user"]
66+
assert audit.action == response_json["entityAudits"][0]["action"]
6567

6668
assert results.total_count == response_json["totalCount"]
6769
assert results._bulk == bulk

tests/unit/aio/test_client.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import pytest
1010
from httpx import Headers
11+
from pydantic.v1 import ValidationError
1112

1213
from pyatlan.client.aio.asset import AsyncAssetClient
1314
from pyatlan.client.aio.batch import AsyncBatch
@@ -2140,7 +2141,7 @@ async def test_asset_client_missing_glossary_guid_raises_invalid_request_error(
21402141
async def test_asset_client_methods_validation_error(client, method, params):
21412142
client_method = getattr(client.asset, method)
21422143
for param_values, error_msg in params:
2143-
with pytest.raises(ValueError) as err:
2144+
with pytest.raises(ValidationError) as err:
21442145
await client_method(*param_values)
21452146
assert error_msg in str(err.value)
21462147

@@ -2150,7 +2151,7 @@ async def test_asset_client_methods_validation_error(client, method, params):
21502151
async def test_admin_client_methods_validation_error(client, method, params):
21512152
client_method = getattr(client.admin, method)
21522153
for param_values, error_msg in params:
2153-
with pytest.raises(ValueError) as err:
2154+
with pytest.raises(ValidationError) as err:
21542155
await client_method(*param_values)
21552156
assert error_msg in str(err.value)
21562157

@@ -2160,7 +2161,7 @@ async def test_admin_client_methods_validation_error(client, method, params):
21602161
async def test_async_audit_client_methods_validation_error(client, method, params):
21612162
client_method = getattr(client.audit, method)
21622163
for param_values, error_msg in params:
2163-
with pytest.raises(ValueError) as err:
2164+
with pytest.raises(ValidationError) as err:
21642165
await client_method(*param_values)
21652166
assert error_msg in str(err.value)
21662167

@@ -2170,7 +2171,7 @@ async def test_async_audit_client_methods_validation_error(client, method, param
21702171
async def test_async_group_client_methods_validation_error(client, method, params):
21712172
client_method = getattr(client.group, method)
21722173
for param_values, error_msg in params:
2173-
with pytest.raises(ValueError) as err:
2174+
with pytest.raises(ValidationError) as err:
21742175
await client_method(*param_values)
21752176
assert error_msg in str(err.value)
21762177

@@ -2180,7 +2181,7 @@ async def test_async_group_client_methods_validation_error(client, method, param
21802181
async def test_role_client_methods_validation_error(client, method, params):
21812182
client_method = getattr(client.role, method)
21822183
for param_values, error_msg in params:
2183-
with pytest.raises(ValueError) as err:
2184+
with pytest.raises(ValidationError) as err:
21842185
await client_method(*param_values)
21852186
assert error_msg in str(err.value)
21862187

@@ -2190,7 +2191,7 @@ async def test_role_client_methods_validation_error(client, method, params):
21902191
async def test_async_search_log_client_methods_validation_error(client, method, params):
21912192
client_method = getattr(client.search_log, method)
21922193
for param_values, error_msg in params:
2193-
with pytest.raises(ValueError) as err:
2194+
with pytest.raises(ValidationError) as err:
21942195
await client_method(*param_values)
21952196
assert error_msg in str(err.value)
21962197

@@ -2200,7 +2201,7 @@ async def test_async_search_log_client_methods_validation_error(client, method,
22002201
async def test_async_token_client_methods_validation_error(client, method, params):
22012202
client_method = getattr(client.token, method)
22022203
for param_values, error_msg in params:
2203-
with pytest.raises(ValueError) as err:
2204+
with pytest.raises(ValidationError) as err:
22042205
await client_method(*param_values)
22052206
assert error_msg in str(err.value)
22062207

@@ -2210,7 +2211,7 @@ async def test_async_token_client_methods_validation_error(client, method, param
22102211
async def test_async_typedef_client_methods_validation_error(client, method, params):
22112212
client_method = getattr(client.typedef, method)
22122213
for param_values, error_msg in params:
2213-
with pytest.raises(ValueError) as err:
2214+
with pytest.raises(ValidationError) as err:
22142215
await client_method(*param_values)
22152216
assert error_msg in str(err.value)
22162217

@@ -2220,7 +2221,7 @@ async def test_async_typedef_client_methods_validation_error(client, method, par
22202221
async def test_async_user_client_methods_validation_error(client, method, params):
22212222
client_method = getattr(client.user, method)
22222223
for param_values, error_msg in params:
2223-
with pytest.raises(ValueError) as err:
2224+
with pytest.raises(ValidationError) as err:
22242225
await client_method(*param_values)
22252226
assert error_msg in str(err.value)
22262227

tests/unit/aio/test_credential_client.py

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest.mock import Mock
44

55
import pytest
6+
from pydantic.v1 import ValidationError
67

78
from pyatlan.client.aio.credential import AsyncCredentialClient
89
from pyatlan.client.common import AsyncApiCaller
@@ -21,20 +22,12 @@
2122
"ATLAN-PYTHON-400-054 Credentials provided did not work: failed"
2223
)
2324
TEST_INVALID_GUID_GET_VALIDATION_ERR = (
24-
"1 validation error for Get\nguid\n str type expected"
25-
)
26-
TEST_INVALID_GUID_PURGE_BY_GUID_VALIDATION_ERR = (
27-
"1 validation error for PurgeByGuid\nguid\n str type expected"
28-
)
29-
TEST_INVALID_CRED_TEST_VALIDATION_ERR = (
30-
"1 validation error for Test\ncredential\n value is not a valid dict"
31-
)
32-
TEST_INVALID_CRED_TEST_UPDATE_VALIDATION_ERR = (
33-
"1 validation error for TestAndUpdate\ncredential\n value is not a valid dict"
34-
)
35-
TEST_INVALID_CRED_CREATOR_VALIDATION_ERR = (
36-
"1 validation error for Creator\ncredential\n value is not a valid dict"
25+
"1 validation error for Get\nguid\n str type expected (type=type_error.str)"
3726
)
27+
TEST_INVALID_GUID_PURGE_BY_GUID_VALIDATION_ERR = "1 validation error for PurgeByGuid\nguid\n str type expected (type=type_error.str)"
28+
TEST_INVALID_CRED_TEST_VALIDATION_ERR = "1 validation error for Test\ncredential\n value is not a valid dict (type=type_error.dict)"
29+
TEST_INVALID_CRED_TEST_UPDATE_VALIDATION_ERR = "1 validation error for TestAndUpdate\ncredential\n value is not a valid dict (type=type_error.dict)"
30+
TEST_INVALID_CRED_CREATOR_VALIDATION_ERR = "1 validation error for Creator\ncredential\n value is not a valid dict (type=type_error.dict)"
3831
TEST_INVALID_API_CALLER_PARAMETER_TYPE = (
3932
"ATLAN-PYTHON-400-048 Invalid parameter type for client should be AsyncApiCaller"
4033
)
@@ -102,29 +95,29 @@ async def test_init_when_wrong_class_raises_exception(test_api_caller):
10295
async def test_cred_get_wrong_params_raises_validation_error(
10396
test_guid, client: AsyncCredentialClient
10497
):
105-
with pytest.raises(ValueError) as err:
98+
with pytest.raises(ValidationError) as err:
10699
await client.get(guid=test_guid)
107-
assert TEST_INVALID_GUID_GET_VALIDATION_ERR in str(err.value)
100+
assert TEST_INVALID_GUID_GET_VALIDATION_ERR == str(err.value)
108101

109102

110103
@pytest.mark.parametrize("test_credentials", ["invalid_cred", 123])
111104
@pytest.mark.asyncio
112105
async def test_cred_test_wrong_params_raises_validation_error(
113106
test_credentials, client: AsyncCredentialClient
114107
):
115-
with pytest.raises(ValueError) as err:
108+
with pytest.raises(ValidationError) as err:
116109
await client.test(credential=test_credentials)
117-
assert TEST_INVALID_CRED_TEST_VALIDATION_ERR in str(err.value)
110+
assert TEST_INVALID_CRED_TEST_VALIDATION_ERR == str(err.value)
118111

119112

120113
@pytest.mark.parametrize("test_credentials", ["invalid_cred", 123])
121114
@pytest.mark.asyncio
122115
async def test_cred_test_and_update_wrong_params_raises_validation_error(
123116
test_credentials, client: AsyncCredentialClient
124117
):
125-
with pytest.raises(ValueError) as err:
118+
with pytest.raises(ValidationError) as err:
126119
await client.test_and_update(credential=test_credentials)
127-
assert TEST_INVALID_CRED_TEST_UPDATE_VALIDATION_ERR in str(err.value)
120+
assert TEST_INVALID_CRED_TEST_UPDATE_VALIDATION_ERR == str(err.value)
128121

129122

130123
@pytest.mark.parametrize(
@@ -264,7 +257,7 @@ async def test_cred_get_all_invalid_response(mock_api_caller):
264257
async def test_cred_get_all_invalid_params_raises_validation_error(
265258
test_filter, test_limit, test_offset, client: AsyncCredentialClient
266259
):
267-
with pytest.raises(ValueError):
260+
with pytest.raises(ValidationError):
268261
await client.get_all(filter=test_filter, limit=test_limit, offset=test_offset)
269262

270263

@@ -305,7 +298,7 @@ async def test_cred_get_all_partial_response(mock_api_caller):
305298
async def test_cred_get_all_invalid_filter_type(mock_api_caller):
306299
client = AsyncCredentialClient(mock_api_caller)
307300

308-
with pytest.raises(ValueError, match="value is not a valid dict"):
301+
with pytest.raises(ValidationError, match="value is not a valid dict"):
309302
await client.get_all(filter="invalid_filter")
310303

311304

@@ -326,9 +319,9 @@ async def test_cred_get_all_no_results(mock_api_caller):
326319
async def test_cred_creator_wrong_params_raises_validation_error(
327320
create_credentials, client: AsyncCredentialClient
328321
):
329-
with pytest.raises(ValueError) as err:
322+
with pytest.raises(ValidationError) as err:
330323
await client.creator(credential=create_credentials)
331-
assert TEST_INVALID_CRED_CREATOR_VALIDATION_ERR in str(err.value)
324+
assert TEST_INVALID_CRED_CREATOR_VALIDATION_ERR == str(err.value)
332325

333326

334327
@pytest.mark.parametrize(
@@ -407,9 +400,9 @@ async def test_cred_creator_with_test_false_with_username_password(
407400
async def test_cred_purge_by_guid_wrong_params_raises_validation_error(
408401
test_guid, client: AsyncCredentialClient
409402
):
410-
with pytest.raises(ValueError) as err:
403+
with pytest.raises(ValidationError) as err:
411404
await client.purge_by_guid(guid=test_guid)
412-
assert TEST_INVALID_GUID_PURGE_BY_GUID_VALIDATION_ERR in str(err.value)
405+
assert TEST_INVALID_GUID_PURGE_BY_GUID_VALIDATION_ERR == str(err.value)
413406

414407

415408
@pytest.mark.asyncio

tests/unit/aio/test_file_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from unittest.mock import AsyncMock, Mock, patch
77

88
import pytest
9+
from pydantic.v1 import ValidationError
910

1011
from pyatlan.client.aio.client import AsyncAtlanClient
1112
from pyatlan.client.aio.file import AsyncFileClient
@@ -163,7 +164,7 @@ def mock_bad_aiter_bytes(chunk_size=8192):
163164
async def test_async_file_client_methods_validation_error(client, method, params):
164165
client_method = getattr(client.files, method)
165166
for param_values, error_msg in params:
166-
with pytest.raises(ValueError, match=error_msg):
167+
with pytest.raises(ValidationError, match=error_msg):
167168
client_method(*param_values)
168169

169170

tests/unit/aio/test_query_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from unittest.mock import AsyncMock, Mock
55

66
import pytest
7+
from pydantic.v1 import ValidationError
78

89
from pyatlan.client.aio.query import AsyncQueryClient
910
from pyatlan.client.common import AsyncApiCaller
@@ -71,16 +72,13 @@ def test_init_when_wrong_class_raises_exception(test_api_caller):
7172

7273
@pytest.mark.parametrize(
7374
"test_request, error_msg",
74-
[
75-
[None, "none is not an allowed value"],
76-
["123", "value is not a valid dict"],
77-
],
75+
[[None, "none is not an allowed value"], ["123", "value is not a valid dict"]],
7876
)
7977
def test_query_stream_wrong_params_raises_validation_error(
8078
test_request, error_msg, mock_async_api_caller
8179
):
8280
client = AsyncQueryClient(client=mock_async_api_caller)
83-
with pytest.raises(ValueError) as err:
81+
with pytest.raises(ValidationError) as err:
8482
client.stream(request=test_request)
8583
assert error_msg in str(err.value)
8684

tests/unit/aio/test_sso_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from unittest.mock import AsyncMock, Mock
88

99
import pytest
10-
from pydantic.v1 import parse_obj_as
10+
from pydantic.v1 import ValidationError, parse_obj_as
1111

1212
from pyatlan.client.aio.sso import AsyncSSOClient
1313
from pyatlan.client.common import AsyncApiCaller
@@ -86,7 +86,7 @@ def test_init_when_wrong_class_raises_exception(test_api_caller):
8686
def test_sso_get_group_mapping_wrong_params_raises_validation_error(
8787
sso_alias, group_map_id, error_msg
8888
):
89-
with pytest.raises(ValueError) as err:
89+
with pytest.raises(ValidationError) as err:
9090
AsyncSSOClient.get_group_mapping(sso_alias=sso_alias, group_map_id=group_map_id)
9191
assert error_msg in str(err.value)
9292

@@ -101,7 +101,7 @@ def test_sso_get_group_mapping_wrong_params_raises_validation_error(
101101
def test_sso_get_all_group_mapping_wrong_params_raises_validation_error(
102102
sso_alias, error_msg
103103
):
104-
with pytest.raises(ValueError, match=error_msg):
104+
with pytest.raises(ValidationError, match=error_msg):
105105
AsyncSSOClient.get_all_group_mappings(sso_alias=sso_alias)
106106

107107

@@ -119,7 +119,7 @@ def test_sso_get_all_group_mapping_wrong_params_raises_validation_error(
119119
def test_sso_create_group_mapping_wrong_params_raises_validation_error(
120120
sso_alias, atlan_group, sso_group_name, error_msg
121121
):
122-
with pytest.raises(ValueError, match=error_msg):
122+
with pytest.raises(ValidationError, match=error_msg):
123123
AsyncSSOClient.create_group_mapping(
124124
sso_alias=sso_alias, atlan_group=atlan_group, sso_group_name=sso_group_name
125125
)
@@ -160,7 +160,7 @@ def test_sso_create_group_mapping_wrong_params_raises_validation_error(
160160
def test_sso_update_group_mapping_wrong_params_raises_validation_error(
161161
sso_alias, atlan_group, group_map_id, sso_group_name, error_msg
162162
):
163-
with pytest.raises(ValueError, match=error_msg):
163+
with pytest.raises(ValidationError, match=error_msg):
164164
AsyncSSOClient.update_group_mapping(
165165
sso_alias=sso_alias,
166166
atlan_group=atlan_group,
@@ -181,7 +181,7 @@ def test_sso_update_group_mapping_wrong_params_raises_validation_error(
181181
def test_sso_delete_group_mapping_wrong_params_raises_validation_error(
182182
sso_alias, group_map_id, error_msg
183183
):
184-
with pytest.raises(ValueError, match=error_msg):
184+
with pytest.raises(ValidationError, match=error_msg):
185185
AsyncSSOClient.delete_group_mapping(
186186
sso_alias=sso_alias, group_map_id=group_map_id
187187
)

tests/unit/aio/test_task_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from unittest.mock import AsyncMock, Mock
66

77
import pytest
8+
from pydantic.v1 import ValidationError
89

910
from pyatlan.client.aio.task import AsyncTaskClient
1011
from pyatlan.client.common import AsyncApiCaller
@@ -74,16 +75,13 @@ def test_init_when_wrong_class_raises_exception(test_api_caller):
7475

7576
@pytest.mark.parametrize(
7677
"test_request, error_msg",
77-
[
78-
[None, "none is not an allowed value"],
79-
["123", "value is not a valid dict"],
80-
],
78+
[[None, "none is not an allowed value"], ["123", "value is not a valid dict"]],
8179
)
8280
def test_task_search_wrong_params_raises_validation_error(
8381
test_request, error_msg, mock_async_api_caller
8482
):
8583
client = AsyncTaskClient(client=mock_async_api_caller)
86-
with pytest.raises(ValueError) as err:
84+
with pytest.raises(ValidationError) as err:
8785
client.search(request=test_request)
8886
assert error_msg in str(err.value)
8987

tests/unit/aio/test_workflow_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest.mock import AsyncMock, Mock, patch
44

55
import pytest
6+
from pydantic.v1 import ValidationError
67

78
from pyatlan.client.aio.client import AsyncAtlanClient
89
from pyatlan.client.aio.workflow import AsyncWorkflowClient
@@ -176,7 +177,7 @@ def update_response() -> WorkflowResponse:
176177
async def test_async_workflow_client_methods_validation_error(method, params):
177178
client_method = getattr(AsyncAtlanClient().workflow, method)
178179
for param_values, error_msg in params:
179-
with pytest.raises(ValueError, match=error_msg):
180+
with pytest.raises(ValidationError, match=error_msg):
180181
await client_method(*param_values)
181182

182183

0 commit comments

Comments
 (0)