Skip to content

Commit

Permalink
budgeting/test_propsal_api: test search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rine authored and fuzzylogic2000 committed Sep 27, 2022
1 parent 75ba44c commit 2f6f736
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/budgeting/test_proposals_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ def test_proposal_list_filtering(apiclient, module, proposal_factory,
last_week = now - timezone.timedelta(days=7)

proposal_new = proposal_factory(pk=1, module=module, created=now)
proposal_old = proposal_factory(pk=2, module=module, created=last_week)
proposal_old = proposal_factory(pk=2,
module=module,
created=last_week,
name='liqd proposal')

proposal_archived = proposal_factory(pk=3,
module=module,
Expand Down Expand Up @@ -149,6 +152,30 @@ def test_proposal_list_filtering(apiclient, module, proposal_factory,
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 2

# search filter
querystring = '?search=liqd+proposal'
url_tmp = url + querystring
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 1
assert response.data['results'][0]['pk'] == proposal_old.pk

querystring = '?search=2021-'
url_tmp = url + querystring
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 7

querystring = '?search=2022-'
url_tmp = url + querystring
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 1
assert response.data['results'][0]['pk'] == proposal_new.pk

querystring = '?search=2021-00006'
url_tmp = url + querystring
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 1
assert response.data['results'][0]['pk'] == proposal_cat1.pk

# ordering
# positive rating
querystring = '?ordering=-positive_rating_count'
Expand Down Expand Up @@ -184,6 +211,17 @@ def test_proposal_list_filtering(apiclient, module, proposal_factory,
assert len(response.data['results']) == 1
assert response.data['results'][0]['pk'] == proposal_cat2_archived.pk

querystring = '?is_archived=true&search=2022-'
url_tmp = url + querystring
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 0

querystring = '?ordering=-created&search=2021-'
url_tmp = url + querystring
response = apiclient.get(url_tmp)
assert len(response.data['results']) == 7
assert response.data['results'][6]['pk'] == proposal_old.pk

querystring = '?ordering=-positive_rating_count&category=' + \
str(category2.pk)
url_tmp = url + querystring
Expand Down

0 comments on commit 2f6f736

Please sign in to comment.