mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-21 00:21:06 +00:00
26 lines
979 B
Python
26 lines
979 B
Python
![]() |
import unittest
|
||
|
|
||
|
from datahub.utilities.urns.corpuser_urn import CorpuserUrn
|
||
|
from datahub.utilities.urns.error import InvalidUrnError
|
||
|
|
||
|
|
||
|
class TestCorpuserUrn(unittest.TestCase):
|
||
|
def test_parse_urn(self) -> None:
|
||
|
corpuser_urn_str = "urn:li:corpuser:abc"
|
||
|
corpuser_urn = CorpuserUrn.create_from_string(corpuser_urn_str)
|
||
|
assert corpuser_urn.get_type() == CorpuserUrn.ENTITY_TYPE
|
||
|
|
||
|
assert corpuser_urn.get_entity_id() == ["abc"]
|
||
|
assert str(corpuser_urn) == corpuser_urn_str
|
||
|
assert corpuser_urn == CorpuserUrn("corpuser", ["abc"])
|
||
|
assert corpuser_urn == CorpuserUrn.create_from_id("abc")
|
||
|
|
||
|
def test_invalid_urn(self) -> None:
|
||
|
with self.assertRaises(InvalidUrnError):
|
||
|
CorpuserUrn.create_from_string(
|
||
|
"urn:li:abc:(urn:li:dataPlatform:abc,def,prod)"
|
||
|
)
|
||
|
|
||
|
with self.assertRaises(InvalidUrnError):
|
||
|
CorpuserUrn.create_from_string("urn:li:corpuser:(part1,part2)")
|