Skip to content

Commit

Permalink
fixup! Include replica_type in JSONL manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Apr 13, 2024
1 parent 9e8347c commit 6d2edd8
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions test/service/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,24 +1295,27 @@ def test_manifest_content_disposition_header(self):
def test_verbatim_jsonl_manifest(self):
bundle = self._load_canned_bundle(one(self.bundles()))
expected = [
bundle.metadata_files[d]
for d in [
'cell_suspension_0.json',
'project_0.json',
'sequence_file_0.json',
'sequence_file_1.json',
'specimen_from_organism_0.json'
{
'type': replica_type,
'contents': bundle.metadata_files[key],
}
for replica_type, key in [
('cell_suspension', 'cell_suspension_0.json'),
('project', 'project_0.json'),
('file', 'sequence_file_0.json'),
('file', 'sequence_file_1.json'),
('sample', 'specimen_from_organism_0.json')
]
]
response = self._get_manifest(ManifestFormat.verbatim_jsonl, {})
self.assertEqual(200, response.status_code)
response = [
json.loads(row)['contents']
json.loads(row)
for row in response.content.decode().splitlines()
]

def sort_key(hca_doc: JSON) -> str:
return hca_doc['provenance']['document_id']
return hca_doc['contents']['provenance']['document_id']

expected.sort(key=sort_key)
response.sort(key=sort_key)
Expand Down Expand Up @@ -2044,20 +2047,24 @@ def test_jsonl_manifest(self):
response = self._get_manifest(ManifestFormat.verbatim_jsonl, filters={})
self.assertEqual(200, response.status_code)
manifest = [
json.loads(row)['contents']
json.loads(row)
for row in response.content.decode().splitlines()
]
expected = [
entity
{
'type': 'anvil_' + entity_ref.entity_type,
'contents': entity,
}
for bundle in self.bundles()
for entity in self._load_canned_bundle(bundle).entities.values()
for entity_ref, entity in self._load_canned_bundle(bundle).entities.items()
]

def sort_key(anvil_doc):
contents = anvil_doc['contents']
try:
return anvil_doc['datarepo_row_id']
return contents['datarepo_row_id']
except KeyError:
return anvil_doc['description']
return contents['description']

manifest.sort(key=sort_key)
expected.sort(key=sort_key)
Expand Down

0 comments on commit 6d2edd8

Please sign in to comment.