Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6839] fix api1_and_js tests - part 2 #10903

Closed
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
29 changes: 29 additions & 0 deletions api/base/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,35 @@ def parse_query_params(self, query_params):
})
elif self.should_parse_special_query_params(field_name):
query = self.parse_special_query_params(field_name, key, value, query)
elif not isinstance(value, int) and source_field_name == 'target__guids___id':
base_guid, version = Guid.split_guid(value)
cslzchen marked this conversation as resolved.
Show resolved Hide resolved
if base_guid is None and version is None:
raise InvalidFilterValue(
value=value,
field_type='guid',
)
guid_filters = {
field_name: {
'op': 'in',
'value': self.bulk_get_values(value, field),
'source_field_name': source_field_name,
},
}
if version is not None:
guid_filters = {
field_name: {
'op': 'eq',
'value': base_guid,
'source_field_name': 'target__guids___id',
},
'target__versioned_guids__version': {
'op': 'eq',
'value': version,
'source_field_name': 'target__versioned_guids__version',
},
}

query.get(key).update(guid_filters)
else:
query.get(key).update({
field_name: {
Expand Down
3 changes: 2 additions & 1 deletion api_tests/preprints/views/test_preprint_list_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ 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']) == 0
assert len(res.json['data']) == 1
assert preprint_unpublished._id in [d['id'] for d in res.json['data']]


@pytest.mark.django_db
Expand Down
2 changes: 1 addition & 1 deletion api_tests/users/views/test_user_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_claim_unauth_success_with_unknown_email(self, app, url, project, unreg_
def test_claim_unauth_success_with_preprint_id(self, app, url, preprint, unreg_user, mock_mail):
res = app.post_json_api(
url.format(unreg_user._id),
self.payload(email='david@david.son', id=preprint._id),
self.payload(email='david@david.son', id=preprint.get_guid()._id),
cslzchen marked this conversation as resolved.
Show resolved Hide resolved
)
assert res.status_code == 204
assert mock_mail.call_count == 1
Expand Down
Loading