|
3 | 3 |
|
4 | 4 | import pytest |
5 | 5 |
|
| 6 | +from pyatlan.client.atlan import AtlanClient |
| 7 | +from pyatlan.errors import InvalidRequestError |
6 | 8 | from pyatlan.model.assets import AtlasGlossary, DataProduct |
7 | 9 | from pyatlan.model.enums import CertificateStatus, DataProductStatus |
8 | 10 | from pyatlan.model.fluent_search import CompoundQuery, FluentSearch |
|
21 | 23 | ASSETS_PLAYBOOK_FILTER = '{"condition":"AND","isGroupLocked":false,"rules":[]}' |
22 | 24 |
|
23 | 25 |
|
| 26 | +@pytest.fixture(autouse=True) |
| 27 | +def set_env(monkeypatch): |
| 28 | + monkeypatch.setenv("ATLAN_BASE_URL", "https://test.atlan.com") |
| 29 | + monkeypatch.setenv("ATLAN_API_KEY", "test-api-key") |
| 30 | + |
| 31 | + |
| 32 | +@pytest.fixture() |
| 33 | +def client(): |
| 34 | + return AtlanClient() |
| 35 | + |
| 36 | + |
| 37 | +@pytest.fixture() |
| 38 | +def current_client(client, monkeypatch): |
| 39 | + monkeypatch.setattr( |
| 40 | + AtlanClient, |
| 41 | + "get_current_client", |
| 42 | + lambda: client, |
| 43 | + ) |
| 44 | + |
| 45 | + |
24 | 46 | def load_json(respones_dir, filename): |
25 | 47 | with (respones_dir / filename).open() as input_file: |
26 | 48 | return load(input_file) |
@@ -144,6 +166,21 @@ def test_create_for_modification(): |
144 | 166 | _assert_product(test_product) |
145 | 167 |
|
146 | 168 |
|
| 169 | +def test_get_assets_with_missing_dp_asset_dsl(client: AtlanClient): |
| 170 | + data_product = DataProduct() |
| 171 | + data_product.attributes.name = DATA_PRODUCT_NAME |
| 172 | + data_product.parent_domain_qualified_name = DATA_PRODUCT_QUALIFIED_NAME |
| 173 | + data_product.data_product_assets_d_s_l = None |
| 174 | + with pytest.raises( |
| 175 | + InvalidRequestError, |
| 176 | + match=( |
| 177 | + "Missing value for `data_product_assets_d_s_l`, " |
| 178 | + "which is required to retrieve DataProduct assets." |
| 179 | + ), |
| 180 | + ): |
| 181 | + data_product.get_assets(client=client) |
| 182 | + |
| 183 | + |
147 | 184 | def test_trim_to_required(): |
148 | 185 | test_product = DataProduct.create_for_modification( |
149 | 186 | qualified_name=DATA_PRODUCT_QUALIFIED_NAME, |
|
0 commit comments