Skip to content

Commit

Permalink
Merge pull request #10873 from bodintsov/fix/fix_newly_broken_tests_d…
Browse files Browse the repository at this point in the history
…ue_to_project_collection_fix

[ENG-6787] Fixed tests, fixed issues
  • Loading branch information
cslzchen authored Dec 26, 2024
2 parents 5fee1e3 + 45d7615 commit 4ad6cf3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/base/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,5 +619,5 @@ def preprints_queryset(self, base_queryset, auth_user, allow_contribs=True, publ
public_only=public_only,
)
if latest_only:
preprints = [preprint for preprint in preprints if preprint.is_latest_version]
preprints = preprints.filter(pk__in=[obj.pk for obj in preprints if obj.is_latest_version])
return preprints
2 changes: 1 addition & 1 deletion api/collections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def collection_preprints(self, collection, user, latest_only=False):
user=user,
)
if latest_only:
preprints = [preprint for preprint in preprints if preprint.is_latest_version]
preprints = preprints.filter(pk__in=[obj.pk for obj in preprints if obj.is_latest_version])
return preprints

def get_collection_submission(self, check_object_permissions=True):
Expand Down
3 changes: 1 addition & 2 deletions api_tests/nodes/views/test_node_preprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ def test_unpublished_visible_to_admins(
preprint_unpublished,
preprint_published, url):
res = app.get(url, auth=user_admin_contrib.auth)
assert len(res.json['data']) == 2
assert preprint_unpublished._id in [d['id'] for d in res.json['data']]
assert len(res.json['data']) == 1
assert preprint_published._id in [d['id'] for d in res.json['data']]

def test_unpublished_invisible_to_write_contribs(
Expand Down
3 changes: 1 addition & 2 deletions api_tests/preprints/views/test_preprint_list_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ def test_filter_published_false_admin(
res = app.get(
f'{url}filter[is_published]=false',
auth=user_admin_contrib.auth)
assert len(res.json['data']) == 1
assert preprint_unpublished._id in [d['id'] for d in res.json['data']]
assert len(res.json['data']) == 0


@pytest.mark.django_db
Expand Down

0 comments on commit 4ad6cf3

Please sign in to comment.