2022-02-07 18:51:49 +01:00
|
|
|
import datahub.emitter.mcp_builder as builder
|
|
|
|
from datahub.emitter.mce_builder import datahub_guid
|
|
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
|
)
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == "f096b3799fc86a3e5d5d0c083eb1f2a4"
|
|
|
|
|
|
|
|
|
2022-10-13 18:29:54 +00:00
|
|
|
def test_guid_generator_with_backcompat_instance():
|
|
|
|
key = builder.SchemaKey(
|
|
|
|
database="test",
|
|
|
|
schema="Test",
|
|
|
|
platform="mysql",
|
|
|
|
instance=None,
|
|
|
|
backcompat_instance_for_guid="TestInstance",
|
|
|
|
)
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == "f096b3799fc86a3e5d5d0c083eb1f2a4"
|
|
|
|
|
|
|
|
|
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
|
|
|
)
|
2022-03-16 22:57:50 +01:00
|
|
|
guid_datahub = datahub_guid(key.dict(by_alias=True))
|
2022-02-07 18:51:49 +01:00
|
|
|
|
|
|
|
guid = key.guid()
|
|
|
|
assert guid == guid_datahub
|