2022-02-07 18:51:49 +01:00
|
|
|
import datahub.emitter.mcp_builder as builder
|
2023-10-30 14:22:05 -07:00
|
|
|
from datahub.metadata.schema_classes import StatusClass, TelemetryClientIdClass
|
2022-02-07 18:51:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_guid_generator():
|
|
|
|
key = builder.SchemaKey(
|
2022-03-16 22:57:50 +01:00
|
|
|
database="test", schema="Test", platform="mysql", instance="TestInstance"
|
2022-02-07 18:51:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
guid = key.guid()
|
2022-03-16 22:57:50 +01:00
|
|
|
assert guid == "f096b3799fc86a3e5d5d0c083eb1f2a4"
|
2022-02-07 18:51:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_guid_generator_with_empty_instance():
|
|
|
|
key = builder.SchemaKey(
|
2022-03-16 22:57:50 +01:00
|
|
|
database="test",
|
|
|
|
schema="Test",
|
|
|
|
platform="mysql",
|
|
|
|
instance=None,
|
2022-02-07 18:51:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == "693ed953c7192bcf46f8b9db36d71c2b"
|
|
|
|
|
|
|
|
|
2022-03-16 22:57:50 +01:00
|
|
|
def test_guid_generator_with_instance():
|
|
|
|
key = builder.SchemaKey(
|
|
|
|
database="test",
|
|
|
|
schema="Test",
|
|
|
|
platform="mysql",
|
|
|
|
instance="TestInstance",
|
2023-05-23 00:37:16 +05:30
|
|
|
backcompat_env_as_instance=True,
|
2022-03-16 22:57:50 +01:00
|
|
|
)
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == "f096b3799fc86a3e5d5d0c083eb1f2a4"
|
|
|
|
|
|
|
|
|
2023-05-23 00:37:16 +05:30
|
|
|
def test_guid_generator_with_instance_and_env():
|
|
|
|
key = builder.SchemaKey(
|
|
|
|
database="test",
|
|
|
|
schema="Test",
|
|
|
|
platform="mysql",
|
|
|
|
instance="TestInstance",
|
|
|
|
env="PROD",
|
|
|
|
backcompat_env_as_instance=True,
|
|
|
|
)
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == "f096b3799fc86a3e5d5d0c083eb1f2a4"
|
|
|
|
|
|
|
|
assert key.property_dict() == {
|
|
|
|
"database": "test",
|
|
|
|
"schema": "Test",
|
|
|
|
"platform": "mysql",
|
|
|
|
"instance": "TestInstance",
|
|
|
|
"env": "PROD",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def test_guid_generator_with_env():
|
2022-10-13 18:29:54 +00:00
|
|
|
key = builder.SchemaKey(
|
|
|
|
database="test",
|
|
|
|
schema="Test",
|
|
|
|
platform="mysql",
|
|
|
|
instance=None,
|
2023-05-23 00:37:16 +05:30
|
|
|
env="TestInstance",
|
|
|
|
backcompat_env_as_instance=True,
|
2022-10-13 18:29:54 +00:00
|
|
|
)
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == "f096b3799fc86a3e5d5d0c083eb1f2a4"
|
|
|
|
|
2023-05-23 00:37:16 +05:30
|
|
|
assert key.property_dict() == {
|
|
|
|
"database": "test",
|
|
|
|
"schema": "Test",
|
|
|
|
"platform": "mysql",
|
|
|
|
"env": "TestInstance",
|
|
|
|
}
|
|
|
|
|
2022-10-13 18:29:54 +00:00
|
|
|
|
2022-02-07 18:51:49 +01:00
|
|
|
def test_guid_generators():
|
|
|
|
key = builder.SchemaKey(
|
2022-03-16 22:57:50 +01:00
|
|
|
database="test", schema="Test", platform="mysql", instance="TestInstance"
|
2022-02-07 18:51:49 +01:00
|
|
|
)
|
2023-10-04 23:11:06 -04:00
|
|
|
guid_datahub = key.guid()
|
2022-02-07 18:51:49 +01:00
|
|
|
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == guid_datahub
|
2023-10-30 14:22:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_entity_supports_aspect():
|
|
|
|
assert builder.entity_supports_aspect("dataset", StatusClass)
|
|
|
|
assert not builder.entity_supports_aspect("telemetry", StatusClass)
|
|
|
|
|
|
|
|
assert not builder.entity_supports_aspect("dataset", TelemetryClientIdClass)
|
|
|
|
assert builder.entity_supports_aspect("telemetry", TelemetryClientIdClass)
|