Skip to content

Commit

Permalink
fixup! Cover orphans in AnVIL verbatim PFB unit test (#6691)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Nov 15, 2024
1 parent 0eec790 commit 56c9ed8
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions test/service/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2122,12 +2122,32 @@ def hash_entities(entities: dict[EntityReference, JSON]) -> dict[str, JSON]:
return all_entities_by_hash.values(), linked_entities_by_hash.values()

def test_verbatim_pfb_manifest(self):
response = self._get_manifest(ManifestFormat.verbatim_pfb, filters={
'datasets.dataset_id': {'is': ['52ee7665-7033-63f2-a8d9-ce8e32666739']}
})
self.assertEqual(200, response.status_code)
with open(self._data_path('service') / 'verbatim/anvil/pfb_schema.json') as f:
expected_schema = json.load(f)
with open(self._data_path('service') / 'verbatim/anvil/pfb_entities.json') as f:
expected_entities = json.load(f)
self._assert_pfb(expected_schema, expected_entities, response)

def test(expected_schema, expected_entities, filters):
response = self._get_manifest(ManifestFormat.verbatim_pfb, filters)
self.assertEqual(200, response.status_code)
self._assert_pfb(expected_schema, expected_entities, response)

with self.subTest(orphans=True):
test(expected_schema, expected_entities, filters={
'datasets.dataset_id': {'is': ['52ee7665-7033-63f2-a8d9-ce8e32666739']}
})

with self.subTest(orphans=False):
# Dynamically edit out references to the orphaned entities that are
# only expected when filtering by dataset ID
schemas = expected_schema['fields'][2]['type']
metadata_entity = expected_entities[0]['object']['nodes']
for part in [
schemas,
metadata_entity,
expected_entities
]:
filtered = [e for e in part if e['name'] != 'non_schema_orphan_table']
assert len(filtered) < len(part), 'Expected to filter orphan references'
part[:] = filtered
test(expected_schema, expected_entities, filters={})

0 comments on commit 56c9ed8

Please sign in to comment.