diff --git a/dandiapi/zarr/tests/factories.py b/dandiapi/zarr/tests/factories.py index b9e472225..ae6002440 100644 --- a/dandiapi/zarr/tests/factories.py +++ b/dandiapi/zarr/tests/factories.py @@ -14,6 +14,15 @@ class Meta: name = factory.Faker('catch_phrase') dandiset = factory.SubFactory(DandisetFactory) + @factory.post_generation + def ensure_draft_version(obj: ZarrArchive, *args, **kwargs): # type: ignore # noqa: N805, PGH003 + from dandiapi.api.tests.factories import DraftVersionFactory + + if obj.dandiset.versions.filter(version='draft').exists(): + return + + DraftVersionFactory(dandiset=obj.dandiset) + class EmbargoedZarrArchiveFactory(ZarrArchiveFactory): embargoed = True