Skip to content

Commit

Permalink
add test case for new search options
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Dec 13, 2023
1 parent 63d98d6 commit 6be5779
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions api_tests/search/views/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def collection_public(self, user):
return CollectionFactory(creator=user, provider=CollectionProviderFactory(), is_public=True,
status_choices=['', 'asdf', 'lkjh'], collected_type_choices=['', 'asdf', 'lkjh'],
issue_choices=['', '0', '1', '2'], volume_choices=['', '0', '1', '2'],
disease_choices=['illness'], data_type_choices=['realness'],
program_area_choices=['', 'asdf', 'lkjh'])

@pytest.fixture()
Expand Down Expand Up @@ -1000,3 +1001,22 @@ def test_POST_search_collections(
assert res.json['links']['meta']['total'] == 1
assert len(res.json['data']) == 1
assert res.json['data'][0]['id'] == node_with_abstract._id

def test_POST_search_collections_disease_data_type(
self, app, url_collection_search, user, node_one, node_two, collection_public,
node_with_abstract, node_private, registration_collection, registration_one,
registration_two, registration_private, reg_with_abstract):

collection_public.collect_object(node_one, user, disease='illness', data_type='realness')
collection_public.collect_object(node_two, user, data_type='realness')

payload = self.post_payload(disease='illness')
res = app.post_json_api(url_collection_search, payload)
assert res.status_code == 200
assert res.json['links']['meta']['total'] == 2

payload = self.post_payload(data_type='realness')
res = app.post_json_api(url_collection_search, payload)
assert res.status_code == 200
assert res.json['links']['meta']['total'] == 1
assert len(res.json['data']) == 1

0 comments on commit 6be5779

Please sign in to comment.