mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-23 01:22:00 +00:00
24 lines
879 B
Python
24 lines
879 B
Python
![]() |
import unittest
|
||
|
|
||
|
from datahub.utilities.urns.domain_urn import DomainUrn
|
||
|
from datahub.utilities.urns.error import InvalidUrnError
|
||
|
|
||
|
|
||
|
class TestDomainUrn(unittest.TestCase):
|
||
|
def test_parse_urn(self) -> None:
|
||
|
domain_urn_str = "urn:li:domain:abc"
|
||
|
domain_urn = DomainUrn.create_from_string(domain_urn_str)
|
||
|
assert domain_urn.get_type() == DomainUrn.ENTITY_TYPE
|
||
|
|
||
|
assert domain_urn.get_entity_id() == ["abc"]
|
||
|
assert str(domain_urn) == domain_urn_str
|
||
|
assert domain_urn == DomainUrn("domain", ["abc"])
|
||
|
assert domain_urn == DomainUrn.create_from_id("abc")
|
||
|
|
||
|
def test_invalid_urn(self) -> None:
|
||
|
with self.assertRaises(InvalidUrnError):
|
||
|
DomainUrn.create_from_string("urn:li:abc:domain")
|
||
|
|
||
|
with self.assertRaises(InvalidUrnError):
|
||
|
DomainUrn.create_from_string("urn:li:domain:(part1,part2)")
|