mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
Merge pull request #967 from alphagov/fix-param-tests
fix query param testing once and for all. hopefully
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
from urllib.parse import quote
|
from urllib.parse import urlparse, quote, parse_qs
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
@@ -327,24 +327,15 @@ def test_can_show_notifications(
|
|||||||
status=status_argument
|
status=status_argument
|
||||||
) == page.findAll("a", {"download": "download"})[0]['href']
|
) == page.findAll("a", {"download": "download"})[0]['href']
|
||||||
|
|
||||||
assert url_for(
|
|
||||||
'.get_notifications_as_json',
|
|
||||||
service_id=service_one['id'],
|
|
||||||
message_type=message_type,
|
|
||||||
status=status_argument,
|
|
||||||
page=expected_page_argument
|
|
||||||
) == page.find("div", {'data-key': 'notifications'})['data-resource']
|
|
||||||
|
|
||||||
path_to_json = page.find("div", {'data-key': 'notifications'})['data-resource']
|
path_to_json = page.find("div", {'data-key': 'notifications'})['data-resource']
|
||||||
|
|
||||||
assert (
|
url = urlparse(path_to_json)
|
||||||
'/services/{}/notifications/{}.json?status={}&page={}'.format(
|
assert url.path == '/services/{}/notifications/{}.json'.format(service_one['id'], message_type)
|
||||||
service_one['id'], message_type, status_argument, expected_page_argument
|
query_dict = parse_qs(url.query)
|
||||||
) in path_to_json or
|
if status_argument:
|
||||||
'/services/{}/notifications/{}.json?page={}&status={}'.format(
|
assert query_dict['status'] == [status_argument]
|
||||||
service_one['id'], message_type, expected_page_argument, status_argument
|
if expected_page_argument:
|
||||||
) in path_to_json
|
assert query_dict['page'] == [str(expected_page_argument)]
|
||||||
)
|
|
||||||
|
|
||||||
mock_get_notifications.assert_called_with(
|
mock_get_notifications.assert_called_with(
|
||||||
limit_days=7,
|
limit_days=7,
|
||||||
|
|||||||
Reference in New Issue
Block a user