|
11 | 11 | from urllib3 import Retry
|
12 | 12 |
|
13 | 13 | from pyatlan.cache.source_tag_cache import SourceTagName
|
14 |
| -from pyatlan.client.asset import LOGGER, IndexSearchResults |
| 14 | +from pyatlan.client.asset import LOGGER, IndexSearchResults, Persona, Purpose |
15 | 15 | from pyatlan.client.atlan import AtlanClient, client_connection
|
16 | 16 | from pyatlan.model.assets import Asset, AtlasGlossaryTerm, Column, Table
|
17 | 17 | from pyatlan.model.core import AtlanTag, AtlanTagName
|
|
92 | 92 | "with_type_name": "Schema",
|
93 | 93 | "with_user_description": "this",
|
94 | 94 | }
|
| 95 | +EXISTING_PURPOSE_NAME = "Known Issues" |
| 96 | +EXISTING_PERSONA_NAME = "Business Definitions" |
| 97 | + |
| 98 | + |
| 99 | +@pytest.fixture(scope="module") |
| 100 | +def business_definitions_persona(client: AtlanClient): |
| 101 | + return client.asset.find_personas_by_name(EXISTING_PERSONA_NAME)[0] |
| 102 | + |
| 103 | + |
| 104 | +@pytest.fixture(scope="module") |
| 105 | +def known_issues_purpose(client: AtlanClient): |
| 106 | + return client.asset.find_purposes_by_name(EXISTING_PURPOSE_NAME)[0] |
95 | 107 |
|
96 | 108 |
|
97 | 109 | @pytest.fixture(scope="module")
|
@@ -764,6 +776,56 @@ def test_default_sorting(client: AtlanClient):
|
764 | 776 | assert sort_options[1].field == ASSET_GUID
|
765 | 777 |
|
766 | 778 |
|
| 779 | +def test_persona_search( |
| 780 | + client: AtlanClient, |
| 781 | + business_definitions_persona: Persona, |
| 782 | + known_issues_purpose: Purpose, |
| 783 | +): |
| 784 | + request1 = ( |
| 785 | + FluentSearch.select() |
| 786 | + .aggregate("type", Asset.TYPE_NAME.bucket_by()) |
| 787 | + .sort(Asset.CREATE_TIME.order()) |
| 788 | + .page_size(0) # only interested in checking aggregation results |
| 789 | + ).to_request() |
| 790 | + |
| 791 | + request2 = ( |
| 792 | + FluentSearch.select() |
| 793 | + .aggregate("type", Asset.TYPE_NAME.bucket_by()) |
| 794 | + .sort(Asset.CREATE_TIME.order()) |
| 795 | + .page_size(0) # only interested in checking aggregation results |
| 796 | + ).to_request() |
| 797 | + request2.persona = business_definitions_persona.qualified_name |
| 798 | + |
| 799 | + results_without_persona = client.asset.search(request1) |
| 800 | + results_with_persona = client.asset.search(request2) |
| 801 | + |
| 802 | + # Make sure the results are different (total assets count != glossary assets count) |
| 803 | + assert results_without_persona.count != results_with_persona.count |
| 804 | + |
| 805 | + |
| 806 | +def test_purpose_search(client: AtlanClient, known_issues_purpose: Purpose): |
| 807 | + request1 = ( |
| 808 | + FluentSearch.select() |
| 809 | + .aggregate("type", Asset.TYPE_NAME.bucket_by()) |
| 810 | + .sort(Asset.CREATE_TIME.order()) |
| 811 | + .page_size(0) # only interested in checking aggregation results |
| 812 | + ).to_request() |
| 813 | + |
| 814 | + request2 = ( |
| 815 | + FluentSearch.select() |
| 816 | + .aggregate("type", Asset.TYPE_NAME.bucket_by()) |
| 817 | + .sort(Asset.CREATE_TIME.order()) |
| 818 | + .page_size(0) # only interested in checking aggregation results |
| 819 | + ).to_request() |
| 820 | + request2.purpose = known_issues_purpose.qualified_name |
| 821 | + |
| 822 | + results_without_purpose = client.asset.search(request1) |
| 823 | + results_with_purpose = client.asset.search(request2) |
| 824 | + |
| 825 | + # Make sure the results are different (total assets count != assets tagged with "Known issues" count) |
| 826 | + assert results_without_purpose.count != results_with_purpose.count |
| 827 | + |
| 828 | + |
767 | 829 | def test_read_timeout(client: AtlanClient):
|
768 | 830 | request = (FluentSearch().select()).to_request()
|
769 | 831 | with client_connection(read_timeout=0.1, retry=Retry(total=0)) as timed_client:
|
|
0 commit comments