Mayuri Nehate b195b6c123
fix(ingest): encode reserved characters when creating dataset urn (#5977)
Co-authored-by: Harshal Sheth <hsheth2@gmail.com>
2022-09-20 16:59:02 -07:00

30 lines
755 B
Python

import pytest
from datahub.utilities.urn_encoder import UrnEncoder
@pytest.mark.parametrize(
"name",
[
"test-database.test-schema.test-table",
"test_database.test$schema.test+table",
"test&database.%testschema.test*table",
],
)
def test_encode_string_without_reserved_chars_no_change(name):
assert UrnEncoder.encode_string(name) == name
@pytest.mark.parametrize(
"name",
[
"test-database,test-schema,test-table",
"test_database,(test$schema),test+table",
"test&database.test(schema.test*table",
],
)
def test_encode_string_with_reserved_chars(name):
assert UrnEncoder.encode_string(name) == name.replace(",", "%2C").replace(
"(", "%28"
).replace(")", "%29")