2022-02-08 15:28:32 -08:00
|
|
|
import pytest
|
2023-02-27 19:06:16 +05:30
|
|
|
from tests.utils import (
|
|
|
|
delete_urns_from_file,
|
|
|
|
get_frontend_url,
|
|
|
|
ingest_file_via_rest,
|
|
|
|
get_root_urn,
|
|
|
|
)
|
2022-06-30 16:00:50 +05:30
|
|
|
|
2022-02-08 15:28:32 -08:00
|
|
|
|
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
|
|
|
def ingest_cleanup_data(request):
|
|
|
|
print("ingesting deprecation test data")
|
|
|
|
ingest_file_via_rest("tests/deprecation/data.json")
|
|
|
|
yield
|
|
|
|
print("removing deprecation test data")
|
|
|
|
delete_urns_from_file("tests/deprecation/data.json")
|
|
|
|
|
2022-06-30 16:00:50 +05:30
|
|
|
|
2022-02-08 15:28:32 -08:00
|
|
|
@pytest.mark.dependency()
|
|
|
|
def test_healthchecks(wait_for_healthchecks):
|
|
|
|
# Call to wait_for_healthchecks fixture will do the actual functionality.
|
|
|
|
pass
|
|
|
|
|
2022-06-30 16:00:50 +05:30
|
|
|
|
2022-02-08 15:28:32 -08:00
|
|
|
@pytest.mark.dependency(depends=["test_healthchecks"])
|
|
|
|
def test_update_deprecation_all_fields(frontend_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
|
|
|
|
response = frontend_session.post(
|
2022-06-30 16:00:50 +05:30
|
|
|
f"{get_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
|
|
|
}
|
|
|
|
|
|
|
|
response = frontend_session.post(
|
2022-06-30 16:00:50 +05:30
|
|
|
f"{get_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
|
|
|
|
response = frontend_session.post(
|
2022-06-30 16:00:50 +05:30
|
|
|
f"{get_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
|
|
|
|
|
|
|
@pytest.mark.dependency(
|
|
|
|
depends=["test_healthchecks", "test_update_deprecation_all_fields"]
|
|
|
|
)
|
2022-02-08 15:28:32 -08:00
|
|
|
def test_update_deprecation_partial_fields(frontend_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
|
|
|
}
|
|
|
|
|
|
|
|
response = frontend_session.post(
|
2022-06-30 16:00:50 +05:30
|
|
|
f"{get_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
|
|
|
}
|
|
|
|
|
|
|
|
response = frontend_session.post(
|
2022-06-30 16:00:50 +05:30
|
|
|
f"{get_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,
|
|
|
|
}
|