2022-12-28 19:28:38 -05:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
import datahub.metadata.schema_classes as models
|
|
|
|
from datahub.emitter.mcp import MetadataChangeProposalWrapper
|
2025-04-21 00:40:00 -04:00
|
|
|
from datahub.errors import DataHubDeprecationWarning
|
2022-12-28 19:28:38 -05:00
|
|
|
|
|
|
|
|
2025-04-21 00:40:00 -04:00
|
|
|
def test_mcpw_inference() -> None:
|
2022-12-28 19:28:38 -05:00
|
|
|
mcpw = MetadataChangeProposalWrapper(
|
|
|
|
entityUrn="urn:li:dataset:(urn:li:dataPlatform:bigquery,harshal-playground-306419.test_schema.excess_deaths_derived,PROD)",
|
|
|
|
aspect=models.DomainsClass(domains=["urn:li:domain:health"]),
|
|
|
|
)
|
|
|
|
assert mcpw.entityType == "dataset"
|
|
|
|
assert mcpw.aspectName == "domains"
|
|
|
|
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
mcpw = MetadataChangeProposalWrapper(
|
|
|
|
entityUrn="urn:li:dataset:(urn:li:dataPlatform:bigquery,harshal-playground-306419.test_schema.excess_deaths_derived,PROD)",
|
|
|
|
entityType="incorrect",
|
|
|
|
aspect=models.DomainsClass(domains=["urn:li:domain:health"]),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2025-04-21 00:40:00 -04:00
|
|
|
def test_mcpw_case_coercion() -> None:
|
|
|
|
with pytest.warns(DataHubDeprecationWarning):
|
|
|
|
mcpw = MetadataChangeProposalWrapper(
|
|
|
|
entityUrn="urn:li:dataset:(urn:li:dataPlatform:bigquery,harshal-playground-306419.test_schema.excess_deaths_derived,PROD)",
|
|
|
|
entityType="DATASET",
|
|
|
|
aspect=models.DomainsClass(domains=["urn:li:domain:health"]),
|
|
|
|
)
|
|
|
|
assert mcpw.entityType == "dataset"
|
|
|
|
|
|
|
|
|
|
|
|
def test_mcpw_from_obj() -> None:
|
2022-12-28 19:28:38 -05:00
|
|
|
# Checks that the MCPW from_obj() method returns a MCPW instead
|
|
|
|
# of an MCP with a serialized inner aspect object.
|
|
|
|
|
|
|
|
mcpw = MetadataChangeProposalWrapper(
|
|
|
|
entityUrn="urn:li:dataset:(urn:li:dataPlatform:bigquery,harshal-playground-306419.test_schema.excess_deaths_derived,PROD)",
|
|
|
|
aspect=models.DomainsClass(domains=["urn:li:domain:health"]),
|
|
|
|
)
|
|
|
|
|
|
|
|
mcpw2 = MetadataChangeProposalWrapper.from_obj(mcpw.to_obj())
|
|
|
|
|
|
|
|
assert isinstance(mcpw2, MetadataChangeProposalWrapper)
|
|
|
|
assert mcpw == mcpw2
|