|
8 | 8 |
|
9 | 9 | from dandiapi.api.asset_paths import add_asset_paths, add_version_asset_paths
|
10 | 10 | from dandiapi.api.models import Dandiset, Version
|
11 |
| -from dandiapi.api.services.dandiset import _create_dandiset_draft_doi, update_draft_version_doi |
| 11 | +from dandiapi.api.services.dandiset import update_draft_version_doi |
12 | 12 | from dandiapi.api.services.permissions.dandiset import (
|
13 | 13 | add_dandiset_owner,
|
14 | 14 | get_dandiset_owners,
|
@@ -353,21 +353,18 @@ def test_dandiset_rest_embargo_access(
|
353 | 353 |
|
354 | 354 |
|
355 | 355 | @pytest.mark.django_db
|
356 |
| -def test_dandiset_rest_create(api_client, user, mocker): |
| 356 | +def test_dandiset_rest_create(api_client, user): |
357 | 357 | user.first_name = 'John'
|
358 | 358 | user.last_name = 'Doe'
|
359 | 359 | user.save()
|
360 | 360 | api_client.force_authenticate(user=user)
|
361 | 361 | name = 'Test Dandiset'
|
362 | 362 | metadata = {'foo': 'bar'}
|
363 | 363 |
|
364 |
| - mock_create_doi = mocker.patch('dandiapi.api.services.dandiset._create_dandiset_draft_doi') |
365 |
| - |
366 | 364 | response = api_client.post(
|
367 | 365 | '/api/dandisets/', {'name': name, 'metadata': metadata}, format='json'
|
368 | 366 | )
|
369 | 367 |
|
370 |
| - mock_create_doi.assert_called_once() |
371 | 368 | assert response.data == {
|
372 | 369 | 'identifier': DANDISET_ID_RE,
|
373 | 370 | 'created': TIMESTAMP_RE,
|
@@ -640,12 +637,10 @@ def test_dandiset_rest_create_embargoed(api_client, user, mocker):
|
640 | 637 | api_client.force_authenticate(user=user)
|
641 | 638 | name = 'Test Dandiset'
|
642 | 639 | metadata = {'foo': 'bar'}
|
643 |
| - mock_create_doi = mocker.patch('dandiapi.api.services.dandiset._create_dandiset_draft_doi') |
644 | 640 |
|
645 | 641 | response = api_client.post(
|
646 | 642 | '/api/dandisets/?embargo=true', {'name': name, 'metadata': metadata}, format='json'
|
647 | 643 | )
|
648 |
| - mock_create_doi.assert_not_called() |
649 | 644 | assert response.data == {
|
650 | 645 | 'identifier': DANDISET_ID_RE,
|
651 | 646 | 'created': TIMESTAMP_RE,
|
@@ -1363,31 +1358,6 @@ def test_dandiset_list_starred_unauthenticated(api_client):
|
1363 | 1358 | assert response.status_code == 401
|
1364 | 1359 |
|
1365 | 1360 |
|
1366 |
| -@pytest.mark.django_db |
1367 |
| -def test__create_dandiset_draft_doi(draft_version, mocker): |
1368 |
| - """Test the _create_dandiset_draft_doi function directly.""" |
1369 |
| - # Set up mocks |
1370 |
| - mock_generate_doi = mocker.patch('dandiapi.api.doi.generate_doi_data') |
1371 |
| - mock_generate_doi.return_value = ('10.48324/dandi.000123', {'data': {'attributes': {}}}) |
1372 |
| - |
1373 |
| - mock_create_doi = mocker.patch('dandiapi.api.doi.create_or_update_doi') |
1374 |
| - mock_create_doi.return_value = '10.48324/dandi.000123' |
1375 |
| - |
1376 |
| - # Call the function directly |
1377 |
| - _create_dandiset_draft_doi(draft_version) |
1378 |
| - |
1379 |
| - # Verify the mocks were called correctly |
1380 |
| - mock_generate_doi.assert_called_once_with( |
1381 |
| - draft_version, |
1382 |
| - version_doi=False, |
1383 |
| - event=None # Draft DOI |
1384 |
| - ) |
1385 |
| - mock_create_doi.assert_called_once_with({'data': {'attributes': {}}}) |
1386 |
| - |
1387 |
| - # Verify the DOI was stored in the draft version |
1388 |
| - assert draft_version.doi == '10.48324/dandi.000123' |
1389 |
| - |
1390 |
| - |
1391 | 1361 | @pytest.mark.django_db
|
1392 | 1362 | def test_update_draft_version_doi_no_previous_doi(draft_version, mocker):
|
1393 | 1363 | """Test updating a draft DOI when none exists yet."""
|
|
0 commit comments