datahub/metadata-ingestion/tests/unit/test_notebook_urn.py
Xu Wang d04092e634
feat(ingest): add python utility classes for NotebookUrn, CorpuserUrn and CorpGroupUrn (#4469)
* feat: add python utility classes for NotebookUrn, CorpuserUrn and CorpGroupUrn

Co-authored-by: Xu Wang <xu.wang@grandrounds.com>
Co-authored-by: Ravindra Lanka <rslanka@gmail.com>
2022-03-23 16:07:57 -07:00

25 lines
940 B
Python

import unittest
from datahub.utilities.urns.error import InvalidUrnError
from datahub.utilities.urns.notebook_urn import NotebookUrn
class TestNotebookUrn(unittest.TestCase):
def test_parse_urn(self) -> None:
notebook_urn_str = "urn:li:notebook:(querybook,123)"
notebook_urn = NotebookUrn.create_from_string(notebook_urn_str)
assert notebook_urn.get_platform_id() == "querybook"
assert notebook_urn.get_notebook_id() == "123"
assert str(notebook_urn) == notebook_urn_str
assert notebook_urn == NotebookUrn("notebook", ["querybook", "123"])
def test_invalid_urn(self) -> None:
with self.assertRaises(InvalidUrnError):
NotebookUrn.create_from_string(
"urn:li:abc:(urn:li:dataPlatform:abc,def,prod)"
)
with self.assertRaises(InvalidUrnError):
NotebookUrn.create_from_string("urn:li:notebook:(part1,part2,part3)")