Skip to content

Commit

Permalink
Extract variables; rename nested function
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc authored and dsotirho-ucsc committed May 10, 2024
1 parent b3c6b23 commit 5b586f1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,8 @@ def _test_managed_access_manifest(self,
"""
endpoint = config.service_endpoint

special_fields = self.metadata_plugin(catalog).special_fields
metadata_plugin = self.metadata_plugin(catalog)
special_fields = metadata_plugin.special_fields

def bundle_uuids(hit: JSON) -> set[str]:
return {
Expand All @@ -1557,16 +1558,17 @@ def bundle_uuids(hit: JSON) -> set[str]:
response = self._get_url_json(GET, files_url)
public_bundle = self.random.choice(sorted(bundle_uuids(one(response['hits']))))
self.assertNotIn(public_bundle, managed_access_bundles)
all_bundles = {public_bundle, *managed_access_bundles}

filters = {
special_fields.bundle_uuid: {
'is': [public_bundle, *managed_access_bundles]
'is': list(all_bundles)
}
}
params = {'catalog': catalog, 'filters': json.dumps(filters)}
manifest_url = furl(url=endpoint, path='/manifest/files', args=params)

def assert_manifest(expected_bundles):
def test_compact_manifest(expected_bundles):
manifest = BytesIO(self._get_url_content(PUT, manifest_url))
manifest_rows = self._read_csv_manifest(manifest)
all_found_bundles = set()
Expand All @@ -1585,12 +1587,12 @@ def assert_manifest(expected_bundles):
# With authorized credentials, all bundles included in the filters
# should be represented in the manifest
with self._service_account_credentials:
assert_manifest({public_bundle, *managed_access_bundles})
test_compact_manifest(all_bundles)

# Without credentials, only the public bundle should be represented
assert_manifest({public_bundle})
test_compact_manifest({public_bundle})

if ManifestFormat.curl in self.metadata_plugin(catalog).manifest_formats:
if ManifestFormat.curl in metadata_plugin.manifest_formats:
# Create a single-file curl manifest and verify that the OAuth2
# token is present on the command line
managed_access_file_id = one(self.random.choice(files)['files'])['uuid']
Expand Down

0 comments on commit 5b586f1

Please sign in to comment.