Skip to content

Commit

Permalink
Add star count and starred status to Dandiset and Version tests
Browse files Browse the repository at this point in the history
- Updated test cases in test_dandiset.py and test_version.py to include 'star_count' and 'is_starred' fields in the expected responses.
- Ensured consistency across various test scenarios for Dandiset and Version APIs regarding star functionality.
  • Loading branch information
bendichter committed Dec 26, 2024
1 parent 05ed15b commit 61295ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
26 changes: 26 additions & 0 deletions dandiapi/api/tests/test_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def test_dandiset_rest_list(api_client, user, dandiset):
'most_recent_published_version': None,
'contact_person': '',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
}
],
}
Expand Down Expand Up @@ -162,6 +164,8 @@ def expected_serialization(dandiset: Dandiset):
'modified': TIMESTAMP_RE,
'contact_person': contact_person,
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
'draft_version': {
'version': draft_version.version,
'name': draft_version.name,
Expand Down Expand Up @@ -223,6 +227,8 @@ def test_dandiset_rest_list_for_user(api_client, user, dandiset_factory):
'most_recent_published_version': None,
'contact_person': '',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
}
],
}
Expand All @@ -238,6 +244,8 @@ def test_dandiset_rest_retrieve(api_client, dandiset):
'most_recent_published_version': None,
'contact_person': '',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
}


Expand Down Expand Up @@ -279,6 +287,8 @@ def test_dandiset_rest_embargo_access(
'most_recent_published_version': None,
'contact_person': '',
'embargo_status': embargo_status,
'star_count': 0,
'is_starred': False,
}
# This is what unauthorized users should get from the retrieve endpoint
expected_error_message = {'detail': 'Not found.'}
Expand Down Expand Up @@ -354,6 +364,8 @@ def test_dandiset_rest_create(api_client, user):
'modified': TIMESTAMP_RE,
'contact_person': 'Doe, John',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
'draft_version': {
'version': 'draft',
'name': name,
Expand All @@ -366,6 +378,8 @@ def test_dandiset_rest_create(api_client, user):
'modified': TIMESTAMP_RE,
'contact_person': 'Doe, John',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'status': 'Pending',
'created': TIMESTAMP_RE,
Expand Down Expand Up @@ -460,13 +474,17 @@ def test_dandiset_rest_create_with_identifier(api_client, admin_user):
'modified': TIMESTAMP_RE,
'contact_person': 'Doe, John',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'status': 'Pending',
'created': TIMESTAMP_RE,
'modified': TIMESTAMP_RE,
},
'contact_person': 'Doe, John',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
}

# Creating a Dandiset has side affects.
Expand Down Expand Up @@ -568,13 +586,17 @@ def test_dandiset_rest_create_with_contributor(api_client, admin_user):
'modified': TIMESTAMP_RE,
'contact_person': 'Jane Doe',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'status': 'Pending',
'created': TIMESTAMP_RE,
'modified': TIMESTAMP_RE,
},
'contact_person': 'Jane Doe',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
}

# Creating a Dandiset has side affects.
Expand Down Expand Up @@ -647,6 +669,8 @@ def test_dandiset_rest_create_embargoed(api_client, user):
'modified': TIMESTAMP_RE,
'contact_person': 'Doe, John',
'embargo_status': 'EMBARGOED',
'star_count': 0,
'is_starred': False,
'draft_version': {
'version': 'draft',
'name': name,
Expand All @@ -659,6 +683,8 @@ def test_dandiset_rest_create_embargoed(api_client, user):
'modified': TIMESTAMP_RE,
'contact_person': 'Doe, John',
'embargo_status': 'EMBARGOED',
'star_count': 0,
'is_starred': False,
},
'status': 'Pending',
'created': TIMESTAMP_RE,
Expand Down
8 changes: 8 additions & 0 deletions dandiapi/api/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ def test_version_rest_list(api_client, version, draft_version_factory):
'modified': TIMESTAMP_RE,
'contact_person': version.metadata['contributor'][0]['name'],
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'version': version.version,
'name': version.name,
Expand Down Expand Up @@ -455,6 +457,8 @@ def test_version_rest_info(api_client, version):
'modified': TIMESTAMP_RE,
'contact_person': version.metadata['contributor'][0]['name'],
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'version': version.version,
'name': version.name,
Expand Down Expand Up @@ -506,6 +510,8 @@ def test_version_rest_info_with_asset(
'modified': TIMESTAMP_RE,
'contact_person': version.metadata['contributor'][0]['name'],
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'version': version.version,
'name': version.name,
Expand Down Expand Up @@ -583,6 +589,8 @@ def test_version_rest_update(api_client, user, draft_version):
'modified': TIMESTAMP_RE,
'contact_person': 'Vargas, Getúlio',
'embargo_status': 'OPEN',
'star_count': 0,
'is_starred': False,
},
'version': draft_version.version,
'name': new_name,
Expand Down

0 comments on commit 61295ab

Please sign in to comment.