From 9909ea612f354d8d0639f02a1f88f5638bb62302 Mon Sep 17 00:00:00 2001 From: Aseem Bansal Date: Thu, 21 Nov 2024 18:15:10 +0530 Subject: [PATCH] fix(ingest): add test for lowercase --- .../api/source_helpers/test_source_helpers.py | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/metadata-ingestion/tests/unit/api/source_helpers/test_source_helpers.py b/metadata-ingestion/tests/unit/api/source_helpers/test_source_helpers.py index cdfd24554e5e5..a296af38c330d 100644 --- a/metadata-ingestion/tests/unit/api/source_helpers/test_source_helpers.py +++ b/metadata-ingestion/tests/unit/api/source_helpers/test_source_helpers.py @@ -7,7 +7,10 @@ import datahub.metadata.schema_classes as models from datahub.configuration.time_window_config import BaseTimeWindowConfig -from datahub.emitter.mce_builder import make_dataset_urn +from datahub.emitter.mce_builder import ( + make_dataset_urn, + make_dataset_urn_with_platform_instance, +) from datahub.emitter.mcp import MetadataChangeProposalWrapper from datahub.ingestion.api.auto_work_units.auto_dataset_properties_aspect import ( auto_patch_last_modified, @@ -99,6 +102,39 @@ def test_auto_status_aspect(): assert list(auto_status_aspect(initial_wu)) == expected +def test_auto_lowercase_aspects_with_platform_instance(): + mcws = auto_workunit( + [ + MetadataChangeProposalWrapper( + entityUrn=make_dataset_urn_with_platform_instance( + "hive", "mySchema.myTable", platform_instance="Orgeon", env="PROD" + ), + aspect=models.DatasetKeyClass( + "urn:li:dataPlatform:hive", "Orgeon.mySchema.myTable", "PROD" + ), + ), + ] + ) + + expected = [ + *list( + auto_workunit( + [ + MetadataChangeProposalWrapper( + entityUrn="urn:li:dataset:(urn:li:dataPlatform:hive,orgeon.myschema.mytable,PROD)", + aspect=models.DatasetKeyClass( + "urn:li:dataPlatform:hive", + "orgeon.myschema.mytable", + "PROD", + ), + ) + ] + ) + ), + ] + assert list(auto_lowercase_urns(mcws)) == expected + + def test_auto_lowercase_aspects(): mcws = auto_workunit( [