From 25b4929fa1f676c9b41744d43cd1ac3c1c61c017 Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Wed, 30 Oct 2024 09:07:04 -0400 Subject: [PATCH] Revise tests and code for removal of embargoed blob --- dandiapi/api/services/metadata/__init__.py | 4 +-- dandiapi/api/tests/test_version.py | 29 ++++++++-------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/dandiapi/api/services/metadata/__init__.py b/dandiapi/api/services/metadata/__init__.py index 6adef8669..8af08fa97 100644 --- a/dandiapi/api/services/metadata/__init__.py +++ b/dandiapi/api/services/metadata/__init__.py @@ -129,9 +129,7 @@ def _build_validatable_version_metadata(version: Version) -> dict: metadata_for_validation['assetsSummary'] = { 'schemaKey': 'AssetsSummary', 'numberOfBytes': 1 - if version.assets.filter( - Q(blob__size__gt=0) | Q(zarr__size__gt=0) | Q(embargoed_blob__size__gt=0) - ).exists() + if version.assets.filter(Q(blob__size__gt=0) | Q(zarr__size__gt=0)).exists() else 0, 'numberOfFiles': 1 if version.assets.exists() else 0, } diff --git a/dandiapi/api/tests/test_version.py b/dandiapi/api/tests/test_version.py index 550297851..ae114dc6a 100644 --- a/dandiapi/api/tests/test_version.py +++ b/dandiapi/api/tests/test_version.py @@ -359,48 +359,39 @@ def test_version_publish_version(draft_version, asset): @pytest.mark.parametrize( 'asset_type', - ["blob", "embargoed_blob", "zarr"], + ['blob', 'zarr'], ) -@pytest.mark.django_db() +@pytest.mark.django_db def test_version_aggregate_assets_summary( - draft_version_factory, - draft_asset_factory, - embargoed_asset_blob_factory, - zarr_archive_factory, - asset_type + draft_version_factory, draft_asset_factory, zarr_archive_factory, asset_type ): version = draft_version_factory(status=Version.Status.VALID) - if asset_type is 'blob': + if asset_type == 'blob': asset = draft_asset_factory(status=Asset.Status.VALID) - elif asset_type is 'embargoed_blob': - asset = embargoed_asset_blob_factory(dandiset=version.dandiset) - - elif asset_type is 'zarr': + elif asset_type == 'zarr': zarr: ZarrArchive = zarr_archive_factory(status=ZarrArchiveStatus.UPLOADED) - asset = draft_asset_factory(blob=None, embargoed_blob=None, zarr=zarr) + asset = draft_asset_factory(blob=None, zarr=zarr) version.assets.add(asset) version_aggregate_assets_summary(version) version.refresh_from_db() - assert 1 == version.assets.count() + assert version.assets.count() == 1 asset = version.assets.first() - if asset_type is 'blob': + if asset_type == 'blob': assert version.metadata['assetsSummary']['numberOfBytes'] == asset.blob.size - elif asset_type is 'embargoed_blob': - assert version.metadata['assetsSummary']['numberOfBytes'] == asset.embargoed_blob.blob.size - - elif asset_type is 'zarr': + elif asset_type == 'zarr': assert version.metadata['assetsSummary']['numberOfBytes'] == asset.size assert version.metadata['assetsSummary']['numberOfFiles'] == 1 assert version.metadata['assetsSummary']['schemaKey'] == 'AssetsSummary' + @pytest.mark.django_db def test_version_aggregate_assets_summary_metadata_modified( draft_version_factory, draft_asset_factory