Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dandiapi/api/management/commands/create_dev_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from uuid import uuid4

from dandischema.conf import get_instance_config
from django.conf import settings
from dandischema.consts import DANDI_SCHEMA_VERSION
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
import djclick as click
Expand Down Expand Up @@ -69,7 +69,7 @@ def create_dev_dandiset(*, name: str, email: str, num_extra_owners: int):
calculate_sha256(blob_id=asset_blob.blob_id)
asset_blob.refresh_from_db()
asset_metadata = {
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'encodingFormat': 'text/plain',
'schemaKey': 'Asset',
'path': 'foo/bar.txt',
Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/services/version/metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from django.conf import settings
from dandischema.consts import DANDI_SCHEMA_VERSION

from dandiapi.api.models.version import Version

Expand All @@ -18,7 +18,7 @@ def _normalize_version_metadata(raw_version_metadata: dict, name: str, email: st
# not specified in the version_metadata
return {
'schemaKey': 'Dandiset',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'contributor': [
{
'name': name,
Expand Down
6 changes: 3 additions & 3 deletions dandiapi/api/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from allauth.socialaccount.models import SocialAccount
from dandischema.conf import get_instance_config
from dandischema.consts import DANDI_SCHEMA_VERSION
from dandischema.models import AccessType
from django.conf import settings
from django.contrib.auth.models import User
import factory
import faker
Expand Down Expand Up @@ -118,7 +118,7 @@ def metadata(self) -> dict:

metadata = {
**faker.Faker().pydict(value_types=['str', 'float', 'int']),
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'schemaKey': 'Dandiset',
'description': faker.Faker().sentence(),
'access': [
Expand Down Expand Up @@ -234,7 +234,7 @@ class Meta:
def metadata(self) -> dict:
metadata = {
**faker.Faker().pydict(value_types=['str', 'float', 'int']),
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'encodingFormat': 'application/x-nwb',
'schemaKey': 'Asset',
}
Expand Down
23 changes: 12 additions & 11 deletions dandiapi/api/tests/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
from uuid import uuid4

from dandischema.consts import DANDI_SCHEMA_VERSION
from dandischema.models import AccessType
from django.conf import settings
from django.db.utils import IntegrityError
Expand Down Expand Up @@ -179,7 +180,7 @@ def test_asset_total_size(asset_factory, asset_blob_factory, zarr_archive_factor
def test_asset_full_metadata(draft_asset_factory):
raw_metadata = {
'foo': 'bar',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
}
asset: Asset = draft_asset_factory(metadata=raw_metadata)

Expand All @@ -199,7 +200,7 @@ def test_asset_full_metadata(draft_asset_factory):
'contentUrl': [download_url, blob_url],
'contentSize': asset.blob.size,
'digest': asset.blob.digest,
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
}


Expand All @@ -208,7 +209,7 @@ def test_asset_full_metadata_zarr(draft_asset_factory):
zarr_archive = ZarrArchiveFactory.create()
raw_metadata = {
'foo': 'bar',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
}
asset: Asset = draft_asset_factory(metadata=raw_metadata, blob=None, zarr=zarr_archive)

Expand All @@ -230,7 +231,7 @@ def test_asset_full_metadata_zarr(draft_asset_factory):
'digest': asset.digest,
# This should be injected on all zarr assets
'encodingFormat': 'application/x-zarr',
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
}


Expand All @@ -240,7 +241,7 @@ def test_asset_full_metadata_access(
):
raw_metadata = {
'foo': 'bar',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
}
embargoed_zarr_asset: Asset = draft_asset_factory(
metadata=raw_metadata, blob=None, zarr=embargoed_zarr_archive_factory()
Expand Down Expand Up @@ -786,7 +787,7 @@ def test_asset_create_path_validation(api_client, asset_blob, path, expected_sta
api_client.force_authenticate(user=user)

metadata = {
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'encodingFormat': 'application/x-nwb',
'path': path,
}
Expand All @@ -813,7 +814,7 @@ def test_asset_create_conflicting_path(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo/bar.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand All @@ -825,7 +826,7 @@ def test_asset_create_conflicting_path(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo/bar.txt/baz.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand All @@ -837,7 +838,7 @@ def test_asset_create_conflicting_path(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down Expand Up @@ -1253,7 +1254,7 @@ def test_asset_rest_rename(api_client, asset_blob):
api_client.force_authenticate(user=user)

# Create asset
metadata = {'path': 'foo/bar', 'schemaVersion': settings.DANDI_SCHEMA_VERSION}
metadata = {'path': 'foo/bar', 'schemaVersion': DANDI_SCHEMA_VERSION}
asset = add_asset_to_version(
user=user, version=draft_version, asset_blob=asset_blob, metadata=metadata
)
Expand Down Expand Up @@ -1650,7 +1651,7 @@ def test_asset_rest_delete_zarr_modified(
{
'metadata': {
'path': 'sample.zarr',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
'zarr_id': zarr_archive.zarr_id,
},
Expand Down
6 changes: 3 additions & 3 deletions dandiapi/api/tests/test_asset_paths.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from django.conf import settings
from dandischema.consts import DANDI_SCHEMA_VERSION
from django.db.models import Q, QuerySet
import pytest

Expand Down Expand Up @@ -383,7 +383,7 @@ def test_asset_path_ordering(asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'a/z',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)
add_asset_to_version(
Expand All @@ -392,7 +392,7 @@ def test_asset_path_ordering(asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'aa/z',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down
17 changes: 9 additions & 8 deletions dandiapi/api/tests/test_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import urlencode

from dandischema.conf import get_instance_config
from dandischema.consts import DANDI_SCHEMA_VERSION
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.utils import timezone
Expand Down Expand Up @@ -465,8 +466,8 @@ def test_dandiset_rest_create(api_client):
f'{user.last_name}, {user.first_name} ({year}) {name} '
f'(Version draft) [Data set]. DANDI Archive. {url}'
),
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': DANDI_SCHEMA_VERSION,
'schemaKey': 'Dandiset',
'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}],
'repository': settings.DANDI_WEB_APP_URL,
Expand Down Expand Up @@ -548,8 +549,8 @@ def test_dandiset_rest_create_with_identifier(api_client):
f'{user.last_name}, {user.first_name} ({year}) {name} '
f'(Version draft) [Data set]. DANDI Archive. {url}'
),
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': DANDI_SCHEMA_VERSION,
'schemaKey': 'Dandiset',
'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}],
'repository': settings.DANDI_WEB_APP_URL,
Expand Down Expand Up @@ -642,8 +643,8 @@ def test_dandiset_rest_create_with_contributor(api_client):
'url': url,
'dateCreated': UTC_ISO_TIMESTAMP_RE,
'citation': (f'Jane Doe ({year}) {name} (Version draft) [Data set]. DANDI Archive. {url}'),
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': DANDI_SCHEMA_VERSION,
'schemaKey': 'Dandiset',
'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}],
'repository': settings.DANDI_WEB_APP_URL,
Expand Down Expand Up @@ -725,8 +726,8 @@ def test_dandiset_rest_create_embargoed(api_client):
f'{user.last_name}, {user.first_name} ({year}) {name} '
f'(Version draft) [Data set]. DANDI Archive. {url}'
),
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
'schemaVersion': DANDI_SCHEMA_VERSION,
'schemaKey': 'Dandiset',
'access': [
{
Expand Down
19 changes: 10 additions & 9 deletions dandiapi/api/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import TYPE_CHECKING

from dandischema.conf import get_instance_config
from dandischema.consts import DANDI_SCHEMA_VERSION
from dandischema.models import AccessType
from django.conf import settings
from freezegun import freeze_time
Expand Down Expand Up @@ -68,7 +69,7 @@ def test_version_next_published_version_preexisting():
@pytest.mark.django_db
def test_draft_version_metadata_computed():
draft_version = DraftVersionFactory.create()
original_metadata = {'schemaVersion': settings.DANDI_SCHEMA_VERSION}
original_metadata = {'schemaVersion': DANDI_SCHEMA_VERSION}
draft_version.metadata = original_metadata

# Save the version to add computed properties to the metadata
Expand All @@ -91,7 +92,7 @@ def test_draft_version_metadata_computed():
'repository': settings.DANDI_WEB_APP_URL,
'dateCreated': draft_version.dandiset.created.isoformat(),
'access': [{'schemaKey': 'AccessRequirements', 'status': AccessType.OpenAccess.value}],
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
'assetsSummary': {
'numberOfBytes': 0,
'numberOfFiles': 0,
Expand All @@ -106,7 +107,7 @@ def test_draft_version_metadata_computed():
@pytest.mark.django_db
def test_published_version_metadata_computed():
published_version = PublishedVersionFactory.create()
original_metadata = {'schemaVersion': settings.DANDI_SCHEMA_VERSION}
original_metadata = {'schemaVersion': DANDI_SCHEMA_VERSION}
published_version.metadata = original_metadata

# Save the version to add computed properties to the metadata
Expand Down Expand Up @@ -134,7 +135,7 @@ def test_published_version_metadata_computed():
'repository': settings.DANDI_WEB_APP_URL,
'dateCreated': published_version.dandiset.created.isoformat(),
'access': [{'schemaKey': 'AccessRequirements', 'status': AccessType.OpenAccess.value}],
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json',
'@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{DANDI_SCHEMA_VERSION}/context.json',
'assetsSummary': {
'numberOfBytes': 0,
'numberOfFiles': 0,
Expand Down Expand Up @@ -555,9 +556,9 @@ def test_version_rest_update(api_client):
new_metadata = {
'@context': (
'https://raw.githubusercontent.com/dandi/schema/master/releases/'
f'{settings.DANDI_SCHEMA_VERSION}/context.json'
f'{DANDI_SCHEMA_VERSION}/context.json'
),
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'foo': 'bar',
'num': 123,
'list': ['a', 'b', 'c'],
Expand All @@ -576,7 +577,7 @@ def test_version_rest_update(api_client):
url = f'{settings.DANDI_WEB_APP_URL}/dandiset/{draft_version.dandiset.identifier}/draft'
saved_metadata = {
**new_metadata,
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'manifestLocation': [
f'{settings.DANDI_API_URL}/api/dandisets/{draft_version.dandiset.identifier}/versions/draft/assets/'
],
Expand Down Expand Up @@ -646,9 +647,9 @@ def test_version_rest_update_unembargo_in_progress(api_client):
new_metadata = {
'@context': (
'https://raw.githubusercontent.com/dandi/schema/master/releases/'
f'{settings.DANDI_SCHEMA_VERSION}/context.json'
f'{DANDI_SCHEMA_VERSION}/context.json'
),
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
'num': 123,
}

Expand Down
16 changes: 8 additions & 8 deletions dandiapi/api/tests/test_webdav.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from django.conf import settings
from dandischema.consts import DANDI_SCHEMA_VERSION
import pytest

from dandiapi.api.models.dandiset import Dandiset
Expand All @@ -18,7 +18,7 @@ def test_asset_atpath_root_path(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'a.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)
add_asset_to_version(
Expand All @@ -27,7 +27,7 @@ def test_asset_atpath_root_path(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'b.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down Expand Up @@ -73,7 +73,7 @@ def test_asset_atpath_asset(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': path,
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down Expand Up @@ -140,7 +140,7 @@ def test_asset_atpath_folder(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo/bar.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)
add_asset_to_version(
Expand All @@ -149,7 +149,7 @@ def test_asset_atpath_folder(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo/baz.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down Expand Up @@ -209,7 +209,7 @@ def test_asset_atpath_trailing_slash(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down Expand Up @@ -237,7 +237,7 @@ def test_asset_atpath_path_missing(api_client, asset_blob):
asset_blob=asset_blob,
metadata={
'path': 'foo/bar.txt',
'schemaVersion': settings.DANDI_SCHEMA_VERSION,
'schemaVersion': DANDI_SCHEMA_VERSION,
},
)

Expand Down
Loading
Loading