datahub/metadata-ingestion/tests/unit/urns/test_notebook_urn.py
2023-11-30 18:11:36 -05:00

28 lines
999 B
Python

import unittest
import pytest
from datahub.utilities.urns.error import InvalidUrnError
from datahub.utilities.urns.notebook_urn import NotebookUrn
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
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("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)")