From 60fd01d611394ca54d0e07c14f6f51b3800b71a1 Mon Sep 17 00:00:00 2001 From: edunn Date: Wed, 3 Apr 2024 11:31:00 -0700 Subject: [PATCH] remove alternate_ids ancestry test case reverts 95489170 alternate_ids are not considered reliable for this purpose, and the relevant feature requires reimplementation --- ...try_mock_AncestryAlternateIdsTestCase.json | 189 ------------------ .../ancestry/test_ancestry.py | 110 ---------- 2 files changed, 299 deletions(-) delete mode 100644 tests/pds/registrysweepers/ancestry/resources/test_ancestry_mock_AncestryAlternateIdsTestCase.json diff --git a/tests/pds/registrysweepers/ancestry/resources/test_ancestry_mock_AncestryAlternateIdsTestCase.json b/tests/pds/registrysweepers/ancestry/resources/test_ancestry_mock_AncestryAlternateIdsTestCase.json deleted file mode 100644 index 7b56343..0000000 --- a/tests/pds/registrysweepers/ancestry/resources/test_ancestry_mock_AncestryAlternateIdsTestCase.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "--note": [ - "Example history for a bundle with three releases having two collections.", - "One collection (CL/cl) is referenced in the bundle by LID, the other (CLV/clv) by LIDVID.", - "The bundle is renamed between v1 and v2, and the collections are renamed between v2 and v3.", - "Renaming amounts to changing the case from upper to lower for ease of reading, even though this is not a realistic example.", - "Each collection contains a product, though this is not important to this test case." - ], - "get_bundle_ancestry_records": [ - { - "_source": { - "lidvid": "_:_:_:B::1.0" - } - }, - { - "_source": { - "lidvid": "_:_:_:b::2.0" - } - }, - { - "_source": { - "lidvid": "_:_:_:b::3.0" - } - } - ], - "get_collection_ancestry_records_bundles": [ - { - "_source": { - "lidvid": "_:_:_:B::1.0", - "alternate_ids": [ - "_:_:_:B::1.0", - "_:_:_:B", - "_:_:_:b" - ], - "ref_lid_collection": [ - "_:_:_:B:CLV::1.0", - "_:_:_:B:CL" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:b::2.0", - "alternate_ids": [ - "_:_:_:b::2.0", - "_:_:_:b", - "_:_:_:B" - ], - "ref_lid_collection": [ - "_:_:_:b:CLV::2.0", - "_:_:_:b:CL" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:b::3.0", - "alternate_ids": [ - "_:_:_:b::3.0", - "_:_:_:b", - "_:_:_:B" - ], - "ref_lid_collection": [ - "_:_:_:b:clv::3.0", - "_:_:_:b:cl" - ] - } - } - ], - "get_collection_ancestry_records_collections": [ - { - "_source": { - "lidvid": "_:_:_:B:CLV::1.0", - "alternate_ids": [ - "_:_:_:B:CLV::1.0", - "_:_:_:B:CLV", - "_:_:_:b:CLV", - "_:_:_:b:clv" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:B:CL::1.0", - "alternate_ids": [ - "_:_:_:B:CL::1.0", - "_:_:_:B:CL", - "_:_:_:b:CL", - "_:_:_:b:cl" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:b:CLV::2.0", - "alternate_ids": [ - "_:_:_:B:CLV::2.0", - "_:_:_:B:CLV", - "_:_:_:b:CLV", - "_:_:_:b:clv" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:b:CL::2.0", - "alternate_ids": [ - "_:_:_:B:CL::2.0", - "_:_:_:B:CL", - "_:_:_:b:CL", - "_:_:_:b:cl" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:b:clv::3.0", - "alternate_ids": [ - "_:_:_:b:clv::3.0", - "_:_:_:B:CLV", - "_:_:_:b:CLV", - "_:_:_:b:clv" - ] - } - }, - { - "_source": { - "lidvid": "_:_:_:b:cl::3.0", - "alternate_ids": [ - "_:_:_:b:cl::3.0", - "_:_:_:B:CL", - "_:_:_:b:CL", - "_:_:_:b:cl" - ] - } - } - ], - "get_nonaggregate_ancestry_records": [ - { - "_source": { - "collection_lidvid": "_:_:_:B:CLV::1.0", - "product_lidvid": [ - "_:_:_:B:CLV:product::1.0" - ] - } - }, - { - "_source": { - "collection_lidvid": "_:_:_:B:CL::1.0", - "product_lidvid": [ - "_:_:_:B:CL:product::1.0" - ] - } - }, - { - "_source": { - "collection_lidvid": "_:_:_:b:CLV::2.0", - "product_lidvid": [ - "_:_:_:b:CLV:product::2.0" - ] - } - }, - { - "_source": { - "collection_lidvid": "_:_:_:b:CL::2.0", - "product_lidvid": [ - "_:_:_:b:CL:product::2.0" - ] - } - }, - { - "_source": { - "collection_lidvid": "_:_:_:b:clv::3.0", - "product_lidvid": [ - "_:_:_:b:clv:product::3.0" - ] - } - }, - { - "_source": { - "collection_lidvid": "_:_:_:b:cl::3.0", - "product_lidvid": [ - "_:_:_:b:cl:product::3.0" - ] - } - } - ], - "get_orphaned_ancestry_docs": [] -} diff --git a/tests/pds/registrysweepers/ancestry/test_ancestry.py b/tests/pds/registrysweepers/ancestry/test_ancestry.py index 4793ad9..84c7508 100644 --- a/tests/pds/registrysweepers/ancestry/test_ancestry.py +++ b/tests/pds/registrysweepers/ancestry/test_ancestry.py @@ -140,116 +140,6 @@ def test_correct_bulk_update_kvs_are_produced(self): self.assertEqual(SWEEPERS_ANCESTRY_VERSION, update[SWEEPERS_ANCESTRY_VERSION_METADATA_KEY]) -class AncestryAlternateIdsTestCase(unittest.TestCase): - input_file_path = os.path.abspath( - "./tests/pds/registrysweepers/ancestry/resources/test_ancestry_mock_AncestryAlternateIdsTestCase.json" - ) - registry_query_mock = RegistryQueryMock(input_file_path) - - ancestry_records: List[AncestryRecord] = [] - bulk_updates: List[Tuple[str, Dict[str, List]]] = [] - - @classmethod - def setUpClass(cls) -> None: - ancestry.run( - client=None, - registry_mock_query_f=cls.registry_query_mock.get_mocked_query, - ancestry_records_accumulator=cls.ancestry_records, - bulk_updates_sink=cls.bulk_updates, - ) - - cls.bundle_records = [r for r in cls.ancestry_records if r.lidvid.is_bundle()] - cls.collection_records = [r for r in cls.ancestry_records if r.lidvid.is_collection()] - cls.nonaggregate_records = [r for r in cls.ancestry_records if r.lidvid.is_basic_product()] - - cls.records_by_lidvid_str = {str(r.lidvid): r for r in cls.ancestry_records} - cls.bundle_records_by_lidvid_str = {str(r.lidvid): r for r in cls.ancestry_records if r.lidvid.is_bundle()} - cls.collection_records_by_lidvid_str = { - str(r.lidvid): r for r in cls.ancestry_records if r.lidvid.is_collection() - } - cls.nonaggregate_records_by_lidvid_str = { - str(r.lidvid): r for r in cls.ancestry_records if r.lidvid.is_basic_product() - } - - cls.updates_by_lidvid_str = {id: content for id, content in cls.bulk_updates} - - def test_collection_aliases_propagate_from_bundle_collection_lid_references(self): - """ - Test that when a bundle references a collection by LID, its LIDVID is added to the bundle ancestry for the - LIDVIDs of all collection LIDVIDs sharing a LID alias with the referenced collection. - """ - collections = [c for c in self.collection_records if c.lidvid.collection_name.upper() == "CL"] - self.assertEqual(3, len(collections)) - - expected_parent_bundle_lidvids = { - "_:_:_:B::1.0", - "_:_:_:b::2.0", - "_:_:_:b::3.0", - } # all LID-referenced collections should contain ancestry for these three bundles - for collection in collections: - parent_bundle_lidvids = {str(lidvid) for lidvid in collection.parent_bundle_lidvids} - msg = f"Collection {collection} should have parent_bundle_lidvids={expected_parent_bundle_lidvids} (got {parent_bundle_lidvids})" - self.assertSetEqual(expected_parent_bundle_lidvids, parent_bundle_lidvids, msg=msg) - - def test_collection_aliases_do_not_propagate_from_bundle_collection_lidvid_references(self): - """ - Test that when a bundle references a collection by LIDVID, the bundle LIDVID is *not* added to the bundle - ancestry for non-referenced collections which share a LID with the reference collection. - """ - - collection_v1: AncestryRecord = self.collection_records_by_lidvid_str["_:_:_:B:CLV::1.0"] - v1_expected_parent_bundle_lidvids = {"_:_:_:B::1.0"} - self.assertSetEqual(v1_expected_parent_bundle_lidvids, {str(lv) for lv in collection_v1.parent_bundle_lidvids}) - - collection_v2: AncestryRecord = self.collection_records_by_lidvid_str["_:_:_:b:CLV::2.0"] - v2_expected_parent_bundle_lidvids = {"_:_:_:b::2.0"} - self.assertSetEqual(v2_expected_parent_bundle_lidvids, {str(lv) for lv in collection_v2.parent_bundle_lidvids}) - - collection_v3: AncestryRecord = self.collection_records_by_lidvid_str["_:_:_:b:clv::3.0"] - v1_expected_parent_bundle_lidvids = {"_:_:_:b::3.0"} - self.assertSetEqual(v1_expected_parent_bundle_lidvids, {str(lv) for lv in collection_v3.parent_bundle_lidvids}) - - def test_collection_aliases_propagate_from_bundle_collection_lid_references_to_nonaggregates(self): - """ - Test that when a bundle references a collection by LID, its LIDVID is added to the bundle ancestry for all - nonaggregate products within all collections that share a LID alias with it. - """ - collection_records = [r for r in self.collection_records if r.lidvid.collection_name.upper() == "CL"] - collection_lids = [r.lidvid.lid for r in collection_records] - self.assertEqual(3, len(collection_records)) - - products = [p for p in self.nonaggregate_records if p.lidvid.parent_collection_lid in collection_lids] - - expected_parent_bundle_lidvids = { - "_:_:_:B::1.0", - "_:_:_:b::2.0", - "_:_:_:b::3.0", - } # all LID-referenced collections should contain ancestry for these three bundles - for product in products: - parent_bundle_lidvids = {str(lidvid) for lidvid in product.parent_bundle_lidvids} - msg = f"Product {product} should have parent_bundle_lidvids={expected_parent_bundle_lidvids} (got {parent_bundle_lidvids})" - self.assertSetEqual(expected_parent_bundle_lidvids, parent_bundle_lidvids, msg=msg) - - def test_collection_aliases_do_not_propagate_from_bundle_collection_lidvid_references_to_nonaggregates(self): - """ - Test that when a bundle references a collection by LID, the bundle's LIDVID is *not* added to the bundle - ancestry for nonaggregate products within non-referenced collections which share a LID alias with the referenced - collection. - """ - - product_v1: AncestryRecord = self.nonaggregate_records_by_lidvid_str["_:_:_:B:CLV:product::1.0"] - v1_expected_parent_bundle_lidvids = {"_:_:_:B::1.0"} - self.assertSetEqual(v1_expected_parent_bundle_lidvids, {str(lv) for lv in product_v1.parent_bundle_lidvids}) - - product_v2: AncestryRecord = self.nonaggregate_records_by_lidvid_str["_:_:_:b:CLV:product::2.0"] - v2_expected_parent_bundle_lidvids = {"_:_:_:b::2.0"} - self.assertSetEqual(v2_expected_parent_bundle_lidvids, {str(lv) for lv in product_v2.parent_bundle_lidvids}) - - product_v3: AncestryRecord = self.nonaggregate_records_by_lidvid_str["_:_:_:b:clv:product::3.0"] - v1_expected_parent_bundle_lidvids = {"_:_:_:b::3.0"} - self.assertSetEqual(v1_expected_parent_bundle_lidvids, {str(lv) for lv in product_v3.parent_bundle_lidvids}) - - class AncestryMalformedDocsTestCase(unittest.TestCase): input_file_path = os.path.abspath( "./tests/pds/registrysweepers/ancestry/resources/test_ancestry_mock_AncestryMalformedDocsTestCase.json"