diff --git a/src/dags/libs/manifest_analyzer.py b/src/dags/libs/manifest_analyzer.py index 5f5672172396032702f23d12923650553094691f..7f5a09c33673b9d94bc92f5acdc2eb5474ea046d 100644 --- a/src/dags/libs/manifest_analyzer.py +++ b/src/dags/libs/manifest_analyzer.py @@ -98,7 +98,7 @@ class EntityNode(object): for parent in self.parents: if parent.system_srn: # ':' at the end is for showing that it is reference if parent srn was surrogate-key. - if "surrogate-key" in parent.system_srn: + if "surrogate-key" in parent.srn: content = content.replace(parent.srn, f"{parent.system_srn}:") else: content = content.replace(parent.srn, f"{parent.system_srn}") diff --git a/tests/plugin-unit-tests/test_manifest_analyzer.py b/tests/plugin-unit-tests/test_manifest_analyzer.py index f3620fbfe55c96269e206f92d86f6c43d4e20314..c6fd5f65ad85858c19f9553e874a7903b96e538a 100644 --- a/tests/plugin-unit-tests/test_manifest_analyzer.py +++ b/tests/plugin-unit-tests/test_manifest_analyzer.py @@ -204,7 +204,7 @@ class TestManifestAnalyzer(object): assert "surrogate-key:wpc-1" in (e.srn for e in manifest_analyzer.unprocessed_entities) @pytest.mark.parametrize( - "manifest,expected_replaced_srns", + "manifest,system_srn,expected_replaced_srns", [ pytest.param( [ @@ -217,7 +217,8 @@ class TestManifestAnalyzer(object): } ], - "system_srn: surrogate-key:wpc2:", + "test:work-product--WorkProduct:7b37ff0e13ac40a0ac35b7e5ca60e5a7", + "test:work-product--WorkProduct:7b37ff0e13ac40a0ac35b7e5ca60e5a7:", id="Surrogate key" ), pytest.param( @@ -231,12 +232,13 @@ class TestManifestAnalyzer(object): } ], + "osdu:reference-data--ResourceSecurityClassification:RESTRICTED:test", "osdu:reference-data--ResourceSecurityClassification:RESTRICTED:test:", id="Real Ids" ) ] ) - def test_update_parent_srn_with_system_srn(self, manifest, expected_replaced_srns): + def test_update_parent_srn_with_system_srn(self, manifest, system_srn, expected_replaced_srns): data = [ManifestEntity(entity=e, schema="") for e in manifest] token_refresher = AirflowTokenRefresher() manifest_analyzer = ManifestAnalyzer( @@ -246,6 +248,6 @@ class TestManifestAnalyzer(object): for entity in manifest_analyzer.entity_queue(): entity.replace_parents_surrogate_srns() - entity.system_srn = self.process_entity(entity) + entity.system_srn = system_srn if entity.content.get("ref"): assert entity.content["ref"] == expected_replaced_srns