2022-02-08 15:28:32 -08:00
|
|
|
import pytest
|
2023-10-10 16:08:34 +05:30
|
|
|
|
2024-09-27 11:31:25 -05:00
|
|
|
from tests.utils import delete_urns_from_file, get_root_urn, ingest_file_via_rest
|
2022-06-30 16:00:50 +05:30
|
|
|
|
2022-02-08 15:28:32 -08:00
|
|
|
|
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
2024-09-27 11:31:25 -05:00
|
|
|
def ingest_cleanup_data(auth_session, graph_client, request):
|
2022-02-08 15:28:32 -08:00
|
|
|
print("ingesting deprecation test data")
|
2024-09-27 11:31:25 -05:00
|
|
|
ingest_file_via_rest(auth_session, "tests/deprecation/data.json")
|
2022-02-08 15:28:32 -08:00
|
|
|
yield
|
|
|
|
print("removing deprecation test data")
|
2024-09-27 11:31:25 -05:00
|
|
|
delete_urns_from_file(graph_client, "tests/deprecation/data.json")
|
2022-02-08 15:28:32 -08:00
|
|
|
|
2022-06-30 16:00:50 +05:30
|
|
|
|
2022-02-08 15:28:32 -08:00
|
|
|
@pytest.mark.dependency()
|
2024-09-27 11:31:25 -05:00
|
|
|
def test_update_deprecation_all_fields(auth_session):
|
2022-06-30 16:00:50 +05:30
|
|
|
dataset_urn = (
|
|
|
|
"urn:li:dataset:(urn:li:dataPlatform:kafka,test-tags-terms-sample-kafka,PROD)"
|
|
|
|
)
|
2022-02-08 15:28:32 -08:00
|
|
|
|
|
|
|
dataset_json = {
|
|
|
|
"query": """query getDataset($urn: String!) {\n
|
|
|
|
dataset(urn: $urn) {\n
|
|
|
|
deprecation {\n
|
|
|
|
deprecated\n
|
|
|
|
decommissionTime\n
|
|
|
|
note\n
|
|
|
|
actor\n
|
|
|
|
}\n
|
|
|
|
}\n
|
|
|
|
}""",
|
2022-06-30 16:00:50 +05:30
|
|
|
"variables": {"urn": dataset_urn},
|
2022-02-08 15:28:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Fetch tags
|
2024-09-27 11:31:25 -05:00
|
|
|
response = auth_session.post(
|
|
|
|
f"{auth_session.frontend_url()}/api/v2/graphql", json=dataset_json
|
2022-02-08 15:28:32 -08:00
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
res_data = response.json()
|
|
|
|
|
|
|
|
assert res_data
|
|
|
|
assert res_data["data"]
|
|
|
|
assert res_data["data"]["dataset"]
|
|
|
|
assert res_data["data"]["dataset"]["deprecation"] is None
|
|
|
|
|
|
|
|
update_deprecation_json = {
|
|
|
|
"query": """mutation updateDeprecation($input: UpdateDeprecationInput!) {\n
|
|
|
|
updateDeprecation(input: $input)
|
|
|
|
}""",
|
|
|
|
"variables": {
|
|
|
|
"input": {
|
2022-06-30 16:00:50 +05:30
|
|
|
"urn": dataset_urn,
|
|
|
|
"deprecated": True,
|
|
|
|
"note": "My test note",
|
|
|
|
"decommissionTime": 0,
|
2022-02-08 15:28:32 -08:00
|
|
|
}
|
2022-06-30 16:00:50 +05:30
|
|
|
},
|
2022-02-08 15:28:32 -08:00
|
|
|
}
|
|
|
|
|
2024-09-27 11:31:25 -05:00
|
|
|
response = auth_session.post(
|
|
|
|
f"{auth_session.frontend_url()}/api/v2/graphql", json=update_deprecation_json
|
2022-02-08 15:28:32 -08:00
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
res_data = response.json()
|
|
|
|
|
|
|
|
assert res_data
|
|
|
|
assert res_data["data"]
|
|
|
|
assert res_data["data"]["updateDeprecation"] is True
|
|
|
|
|
|
|
|
# Refetch the dataset
|
2024-09-27 11:31:25 -05:00
|
|
|
response = auth_session.post(
|
|
|
|
f"{auth_session.frontend_url()}/api/v2/graphql", json=dataset_json
|
2022-02-08 15:28:32 -08:00
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
res_data = response.json()
|
|
|
|
|
|
|
|
assert res_data
|
|
|
|
assert res_data["data"]
|
|
|
|
assert res_data["data"]["dataset"]
|
|
|
|
assert res_data["data"]["dataset"]["deprecation"] == {
|
2022-06-30 16:00:50 +05:30
|
|
|
"deprecated": True,
|
|
|
|
"decommissionTime": 0,
|
|
|
|
"note": "My test note",
|
2023-02-27 19:06:16 +05:30
|
|
|
"actor": get_root_urn(),
|
2022-02-08 15:28:32 -08:00
|
|
|
}
|
|
|
|
|
2022-06-30 16:00:50 +05:30
|
|
|
|
2024-09-27 11:31:25 -05:00
|
|
|
@pytest.mark.dependency(depends=["test_update_deprecation_all_fields"])
|
|
|
|
def test_update_deprecation_partial_fields(auth_session, ingest_cleanup_data):
|
2022-06-30 16:00:50 +05:30
|
|
|
dataset_urn = (
|
|
|
|
"urn:li:dataset:(urn:li:dataPlatform:kafka,test-tags-terms-sample-kafka,PROD)"
|
|
|
|
)
|
2022-02-08 15:28:32 -08:00
|
|
|
|
|
|
|
update_deprecation_json = {
|
|
|
|
"query": """mutation updateDeprecation($input: UpdateDeprecationInput!) {\n
|
|
|
|
updateDeprecation(input: $input)
|
|
|
|
}""",
|
2022-06-30 16:00:50 +05:30
|
|
|
"variables": {"input": {"urn": dataset_urn, "deprecated": False}},
|
2022-02-08 15:28:32 -08:00
|
|
|
}
|
|
|
|
|
2024-09-27 11:31:25 -05:00
|
|
|
response = auth_session.post(
|
|
|
|
f"{auth_session.frontend_url()}/api/v2/graphql", json=update_deprecation_json
|
2022-02-08 15:28:32 -08:00
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
res_data = response.json()
|
|
|
|
|
|
|
|
assert res_data
|
|
|
|
assert res_data["data"]
|
|
|
|
assert res_data["data"]["updateDeprecation"] is True
|
|
|
|
|
|
|
|
# Refetch the dataset
|
|
|
|
dataset_json = {
|
|
|
|
"query": """query getDataset($urn: String!) {\n
|
|
|
|
dataset(urn: $urn) {\n
|
|
|
|
deprecation {\n
|
|
|
|
deprecated\n
|
|
|
|
decommissionTime\n
|
|
|
|
note\n
|
|
|
|
actor\n
|
|
|
|
}\n
|
|
|
|
}\n
|
|
|
|
}""",
|
2022-06-30 16:00:50 +05:30
|
|
|
"variables": {"urn": dataset_urn},
|
2022-02-08 15:28:32 -08:00
|
|
|
}
|
|
|
|
|
2024-09-27 11:31:25 -05:00
|
|
|
response = auth_session.post(
|
|
|
|
f"{auth_session.frontend_url()}/api/v2/graphql", json=dataset_json
|
2022-02-08 15:28:32 -08:00
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
res_data = response.json()
|
|
|
|
|
|
|
|
assert res_data
|
|
|
|
assert res_data["data"]
|
|
|
|
assert res_data["data"]["dataset"]
|
|
|
|
assert res_data["data"]["dataset"]["deprecation"] == {
|
2022-06-30 16:00:50 +05:30
|
|
|
"deprecated": False,
|
|
|
|
"note": "",
|
2023-02-27 19:06:16 +05:30
|
|
|
"actor": get_root_urn(),
|
2022-06-30 16:00:50 +05:30
|
|
|
"decommissionTime": None,
|
|
|
|
}
|