|
10 | 10 | import pytest |
11 | 11 | from httpx import Headers |
12 | 12 |
|
13 | | -from pyatlan_v9.client.aio.asset import V9AsyncAssetClient as AsyncAssetClient |
14 | 13 | from pyatlan.client.aio.batch import AsyncBatch |
| 14 | +from pyatlan.client.common import Search |
| 15 | +from pyatlan.client.common.asset import LOGGER as SHARED_LOGGER |
| 16 | +from pyatlan.model.aio.asset import AsyncIndexSearchResults |
| 17 | +from pyatlan.utils import get_python_version |
| 18 | +from pyatlan_v9.client.aio.asset import V9AsyncAssetClient as AsyncAssetClient |
15 | 19 | from pyatlan_v9.client.aio.atlan import AsyncAtlanClient |
16 | 20 | from pyatlan_v9.client.aio.group import V9AsyncGroupClient as AsyncGroupClient |
17 | | -from pyatlan_v9.client.aio.search_log import V9AsyncSearchLogClient as AsyncSearchLogClient |
| 21 | +from pyatlan_v9.client.aio.search_log import ( |
| 22 | + V9AsyncSearchLogClient as AsyncSearchLogClient, |
| 23 | +) |
18 | 24 | from pyatlan_v9.client.aio.typedef import V9AsyncTypeDefClient as AsyncTypeDefClient |
19 | 25 | from pyatlan_v9.client.aio.user import V9AsyncUserClient as AsyncUserClient |
20 | 26 | from pyatlan_v9.client.asset import CustomMetadataHandling |
21 | | -from pyatlan.client.common import Search |
22 | | -from pyatlan.client.common.asset import LOGGER as SHARED_LOGGER |
23 | 27 | from pyatlan_v9.errors import ( |
24 | 28 | ERROR_CODE_FOR_HTTP_STATUS, |
25 | 29 | ApiError, |
|
28 | 32 | InvalidRequestError, |
29 | 33 | NotFoundError, |
30 | 34 | ) |
31 | | -from pyatlan.model.aio.asset import AsyncIndexSearchResults |
32 | | -from pyatlan.model.assets import ( |
33 | | - AtlasGlossaryTerm as LegacyAtlasGlossaryTerm, |
34 | | -) |
35 | 35 | from pyatlan_v9.model.assets import ( |
36 | 36 | Asset, |
37 | 37 | AtlasGlossary, |
|
49 | 49 | AtlanConnectorType, |
50 | 50 | CertificateStatus, |
51 | 51 | LineageDirection, |
52 | | - SaveSemantic, |
53 | 52 | SortOrder, |
54 | 53 | ) |
55 | 54 | from pyatlan_v9.model.fluent_search import CompoundQuery, FluentSearch |
|
60 | 59 | from pyatlan_v9.model.search_log import SearchLogRequest |
61 | 60 | from pyatlan_v9.model.typedef import EnumDef |
62 | 61 | from pyatlan_v9.model.user import AtlanUser, UserRequest |
63 | | -from pyatlan.utils import get_python_version |
64 | | -from tests.unit.constants import ( |
65 | | - TEST_ADMIN_CLIENT_METHODS, |
66 | | - TEST_ASSET_CLIENT_METHODS_ASYNC, |
67 | | - TEST_AUDIT_CLIENT_METHODS, |
68 | | - TEST_GROUP_CLIENT_METHODS, |
69 | | - TEST_ROLE_CLIENT_METHODS, |
70 | | - TEST_SL_CLIENT_METHODS, |
71 | | - TEST_TOKEN_CLIENT_METHODS, |
72 | | - TEST_TYPEDEF_CLIENT_METHODS, |
73 | | - TEST_USER_CLIENT_METHODS, |
74 | | -) |
75 | 62 | from tests.unit.model.constants import ( |
76 | 63 | CONNECTION_NAME, |
77 | 64 | CONNECTOR_TYPE, |
|
84 | 71 | PERSONA_NAME, |
85 | 72 | PURPOSE_NAME, |
86 | 73 | ) |
| 74 | +from tests_v9.unit.constants import ( |
| 75 | + TEST_ADMIN_CLIENT_METHODS, |
| 76 | + TEST_ASSET_CLIENT_METHODS_ASYNC, |
| 77 | + TEST_AUDIT_CLIENT_METHODS, |
| 78 | + TEST_GROUP_CLIENT_METHODS, |
| 79 | + TEST_ROLE_CLIENT_METHODS, |
| 80 | + TEST_SL_CLIENT_METHODS, |
| 81 | + TEST_TOKEN_CLIENT_METHODS, |
| 82 | + TEST_TYPEDEF_CLIENT_METHODS, |
| 83 | + TEST_USER_CLIENT_METHODS, |
| 84 | +) |
87 | 85 |
|
88 | 86 | V9_TEST_ASSET_CLIENT_METHODS_ASYNC = { |
89 | 87 | **TEST_ASSET_CLIENT_METHODS_ASYNC, |
@@ -374,7 +372,9 @@ async def test_append_terms_invalid_parameters_raises_error( |
374 | 372 | ), |
375 | 373 | ], |
376 | 374 | ) |
377 | | -@patch("pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock) |
| 375 | +@patch( |
| 376 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 377 | +) |
378 | 378 | @pytest.mark.asyncio |
379 | 379 | async def test_append_terms_asset_retrieval_errors( |
380 | 380 | mock_aexecute, |
@@ -407,10 +407,12 @@ async def test_append_with_valid_guid_and_no_terms_returns_asset(): |
407 | 407 | terms = [] |
408 | 408 |
|
409 | 409 | with patch( |
410 | | - "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 410 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", |
| 411 | + new_callable=AsyncMock, |
411 | 412 | ) as mock_aexecute: |
412 | 413 | with patch( |
413 | | - "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", new_callable=AsyncMock |
| 414 | + "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", |
| 415 | + new_callable=AsyncMock, |
414 | 416 | ) as mock_save: |
415 | 417 | # Set up async mock for search results |
416 | 418 | mock_results = AsyncMock() |
@@ -447,10 +449,12 @@ async def test_append_with_valid_guid_when_no_terms_present_returns_asset_with_g |
447 | 449 | terms = [AtlasGlossaryTerm(qualified_name="term1")] |
448 | 450 |
|
449 | 451 | with patch( |
450 | | - "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 452 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", |
| 453 | + new_callable=AsyncMock, |
451 | 454 | ) as mock_aexecute: |
452 | 455 | with patch( |
453 | | - "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", new_callable=AsyncMock |
| 456 | + "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", |
| 457 | + new_callable=AsyncMock, |
454 | 458 | ) as mock_save: |
455 | 459 | # Set up async mock for search results |
456 | 460 | mock_results = AsyncMock() |
@@ -490,10 +494,12 @@ async def test_append_with_valid_guid_when_terms_present_returns_asset_with_comb |
490 | 494 | terms = [new_term] |
491 | 495 |
|
492 | 496 | with patch( |
493 | | - "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 497 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", |
| 498 | + new_callable=AsyncMock, |
494 | 499 | ) as mock_aexecute: |
495 | 500 | with patch( |
496 | | - "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", new_callable=AsyncMock |
| 501 | + "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", |
| 502 | + new_callable=AsyncMock, |
497 | 503 | ) as mock_save: |
498 | 504 | # Set up async mock for search results |
499 | 505 | mock_results = AsyncMock() |
@@ -604,7 +610,9 @@ async def test_replace_terms_invalid_parameters_raises_error( |
604 | 610 | ), |
605 | 611 | ], |
606 | 612 | ) |
607 | | -@patch("pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock) |
| 613 | +@patch( |
| 614 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 615 | +) |
608 | 616 | @pytest.mark.asyncio |
609 | 617 | async def test_replace_terms_asset_retrieval_errors( |
610 | 618 | mock_aexecute, |
@@ -640,10 +648,12 @@ async def test_replace_terms(): |
640 | 648 | terms = [AtlasGlossaryTerm(qualified_name="new_term")] |
641 | 649 |
|
642 | 650 | with patch( |
643 | | - "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 651 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", |
| 652 | + new_callable=AsyncMock, |
644 | 653 | ) as mock_aexecute: |
645 | 654 | with patch( |
646 | | - "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", new_callable=AsyncMock |
| 655 | + "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", |
| 656 | + new_callable=AsyncMock, |
647 | 657 | ) as mock_save: |
648 | 658 | # Set up async mock for search results |
649 | 659 | mock_results = AsyncMock() |
@@ -750,7 +760,9 @@ async def test_remove_terms_invalid_parameters_raises_error( |
750 | 760 | ), |
751 | 761 | ], |
752 | 762 | ) |
753 | | -@patch("pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock) |
| 763 | +@patch( |
| 764 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 765 | +) |
754 | 766 | @pytest.mark.asyncio |
755 | 767 | async def test_remove_terms_asset_retrieval_errors( |
756 | 768 | mock_aexecute, |
@@ -789,10 +801,12 @@ async def test_remove_with_valid_guid_when_terms_present_returns_asset_with_term |
789 | 801 | table.attributes.meanings = [existing_term, other_term] |
790 | 802 |
|
791 | 803 | with patch( |
792 | | - "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", new_callable=AsyncMock |
| 804 | + "pyatlan_v9.model.fluent_search.FluentSearch.execute_async", |
| 805 | + new_callable=AsyncMock, |
793 | 806 | ) as mock_aexecute: |
794 | 807 | with patch( |
795 | | - "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", new_callable=AsyncMock |
| 808 | + "pyatlan_v9.client.aio.asset.V9AsyncAssetClient.save", |
| 809 | + new_callable=AsyncMock, |
796 | 810 | ) as mock_save: |
797 | 811 | # Set up async mock for search results |
798 | 812 | mock_results = AsyncMock() |
@@ -1147,7 +1161,9 @@ def get_request(*args, **kwargs): |
1147 | 1161 | GLOSSARY_NAME, |
1148 | 1162 | None, |
1149 | 1163 | "1 validation error for FindCategoryByName\nname\n ensure this value has at least 1 characters", |
1150 | | - marks=pytest.mark.skip(reason="v9: name validation happens deeper in call chain, not at model level"), |
| 1164 | + marks=pytest.mark.skip( |
| 1165 | + reason="v9: name validation happens deeper in call chain, not at model level" |
| 1166 | + ), |
1151 | 1167 | ), |
1152 | 1168 | ( |
1153 | 1169 | 1, |
@@ -1448,7 +1464,9 @@ def get_request(*args, **kwargs): |
1448 | 1464 | GLOSSARY_NAME, |
1449 | 1465 | None, |
1450 | 1466 | "1 validation error for FindTermByName\nname\n ensure this value has at least 1 characters", |
1451 | | - marks=pytest.mark.skip(reason="v9: name validation happens deeper in call chain, not at model level"), |
| 1467 | + marks=pytest.mark.skip( |
| 1468 | + reason="v9: name validation happens deeper in call chain, not at model level" |
| 1469 | + ), |
1452 | 1470 | ), |
1453 | 1471 | ( |
1454 | 1472 | 1, |
@@ -2117,7 +2135,9 @@ async def test_user_create_with_info( |
2117 | 2135 | mock_async_api_caller.reset_mock() |
2118 | 2136 |
|
2119 | 2137 |
|
2120 | | -@pytest.mark.skip(reason="Legacy AsyncTypeDefClient returns pydantic EnumDef, can't compare with v9 msgspec EnumDef") |
| 2138 | +@pytest.mark.skip( |
| 2139 | + reason="Legacy AsyncTypeDefClient returns pydantic EnumDef, can't compare with v9 msgspec EnumDef" |
| 2140 | +) |
2121 | 2141 | @pytest.mark.asyncio |
2122 | 2142 | async def test_typedef_get_by_name(mock_async_api_caller, type_def_get_by_name_json): |
2123 | 2143 | client = AsyncTypeDefClient(mock_async_api_caller) |
@@ -2576,8 +2596,8 @@ async def test_add_when_capture_failure_false_then_exception_raised( |
2576 | 2596 | assert 0 == len(sut.created) |
2577 | 2597 | assert 0 == len(sut.updated) |
2578 | 2598 |
|
2579 | | - @patch.object(LegacyAtlasGlossaryTerm, "trim_to_required") |
2580 | | - @patch.object(LegacyAtlasGlossaryTerm, "ref_by_guid") |
| 2599 | + @patch.object(AtlasGlossaryTerm, "trim_to_required") |
| 2600 | + @patch.object(AtlasGlossaryTerm, "ref_by_guid") |
2581 | 2601 | @pytest.mark.asyncio |
2582 | 2602 | async def test_term_add( |
2583 | 2603 | self, mock_ref_by_guid, mock_trim_to_required, mock_async_atlan_client |
|
0 commit comments