Skip to content

Commit

Permalink
Add test asset rename
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt committed Sep 27, 2023
1 parent fd676da commit 65cf41f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions dandiapi/api/tests/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,32 @@ def test_asset_create_existing_path(api_client, user, draft_version, asset_blob,
assert resp.status_code == 409


@pytest.mark.django_db
def test_asset_rest_rename(api_client, user, draft_version, asset_blob):
assign_perm('owner', user, draft_version.dandiset)
api_client.force_authenticate(user=user)

# Create asset
metadata = {'path': 'foo/bar', 'schemaVersion': settings.DANDI_SCHEMA_VERSION}
asset = add_asset_to_version(
user=user, version=draft_version, asset_blob=asset_blob, metadata=metadata
)

# Change path and make update request
metadata['path'] = 'foo/bar2'
resp = api_client.put(
f'/api/dandisets/{draft_version.dandiset.identifier}/versions/{draft_version.version}/'
f'assets/{asset.asset_id}/',
{'metadata': metadata, 'blob_id': asset.blob.blob_id},
format='json',
)

# Ensure new asset with new path was created
assert resp.status_code == 200
assert resp.json()['path'] == metadata['path']
assert resp.json()['asset_id'] != str(asset.asset_id)


@pytest.mark.django_db
def test_asset_rest_update(api_client, user, draft_version, asset, asset_blob):
assign_perm('owner', user, draft_version.dandiset)
Expand Down

0 comments on commit 65cf41f

Please sign in to comment.