Skip to content
Merged
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
1 change: 1 addition & 0 deletions api/preprints/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class PreprintSerializer(TaxonomizableSerializerMixin, MetricsSerializerMixin, J
'reviews_state',
'node_is_public',
'tags',
'description',
])
available_metrics = frozenset([
'downloads',
Expand Down
27 changes: 24 additions & 3 deletions api_tests/preprints/filters/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def preprint_one(self, user, project_one, provider_one, subject_one):
creator=user,
project=project_one,
provider=provider_one,
subjects=[[subject_one._id]])
subjects=[[subject_one._id]],
description='test1'
)
preprint_one.original_publication_date = '2013-12-25 10:09:08.070605+00:00'
preprint_one.save()
return preprint_one
Expand All @@ -68,7 +70,9 @@ def preprint_two(self, user, project_two, provider_two, subject_two):
project=project_two,
filename='howto_reason.txt',
provider=provider_two,
subjects=[[subject_two._id]])
subjects=[[subject_two._id]],
description='2test'
)
preprint_two.created = '2013-12-11 10:09:08.070605+00:00'
preprint_two.date_published = '2013-12-11 10:09:08.070605+00:00'
preprint_two.original_publication_date = '2013-12-11 10:09:08.070605+00:00'
Expand All @@ -84,7 +88,9 @@ def preprint_three(
project=project_three,
filename='darn_reason.txt',
provider=provider_three,
subjects=[[subject_one._id], [subject_two._id]])
subjects=[[subject_one._id], [subject_two._id]],
description='new preprint'
)
preprint_three.created = '2013-12-11 10:09:08.070605+00:00'
preprint_three.date_published = '2013-12-11 10:09:08.070605+00:00'
preprint_three.original_publication_date = '2013-12-11 10:09:08.070605+00:00'
Expand Down Expand Up @@ -129,6 +135,10 @@ def is_published_and_modified_url(self, url):
def node_is_public_url(self, url):
return f'{url}filter[node_is_public]='

@pytest.fixture()
def description_url(self, url):
return f'{url}filter[description]='

def test_provider_filter_null(self, app, user, provider_url):
expected = []
res = app.get(f'{provider_url}null', auth=user.auth)
Expand Down Expand Up @@ -351,3 +361,14 @@ def actual():
expected.update(
[p._id for p in preprints if p.provider_id == preprint.provider_id])
assert expected == actual()

def test_description_filter(
self, app, user, description_url, preprint_one, preprint_two, preprint_three):
expected = {preprint_one._id, preprint_two._id}
res = app.get(
description_url + 'tes',
auth=user.auth
)
actual = {preprint['id'] for preprint in res.json['data']}
assert expected == actual
assert preprint_three._id not in res.json['data']
Loading