Skip to content

Commit

Permalink
remove alternate_ids ancestry test case
Browse files Browse the repository at this point in the history
reverts 9548917
alternate_ids are not considered reliable for this purpose, and the relevant feature requires reimplementation
  • Loading branch information
alexdunnjpl committed Apr 3, 2024
1 parent 8f9c27d commit 60fd01d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 299 deletions.

This file was deleted.

110 changes: 0 additions & 110 deletions tests/pds/registrysweepers/ancestry/test_ancestry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 60fd01d

Please sign in to comment.