mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 09:29:49 -04:00
Make test for activity page more thorough
This commit paramaterizes the test for the activity page, so that it checks all combinations of template type and notification status.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import pytest
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import json
|
import json
|
||||||
@@ -78,12 +79,38 @@ def test_should_show_updates_for_one_job_as_json(
|
|||||||
assert 'Uploaded by Test User on 1 January at 11:09' in content['status']
|
assert 'Uploaded by Test User on 1 January at 11:09' in content['status']
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"message_type,page_title", [
|
||||||
|
('email', 'Emails'),
|
||||||
|
('sms', 'Text messages')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"status_argument, expected_api_call", [
|
||||||
|
(
|
||||||
|
'delivered',
|
||||||
|
['delivered']
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'failed',
|
||||||
|
['failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'delivered,failed',
|
||||||
|
['delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
def test_can_see_sms(
|
def test_can_see_sms(
|
||||||
app_,
|
app_,
|
||||||
service_one,
|
service_one,
|
||||||
active_user_with_permissions,
|
active_user_with_permissions,
|
||||||
mock_get_notifications,
|
mock_get_notifications,
|
||||||
mocker
|
mocker,
|
||||||
|
message_type,
|
||||||
|
page_title,
|
||||||
|
status_argument,
|
||||||
|
expected_api_call
|
||||||
):
|
):
|
||||||
with app_.test_request_context():
|
with app_.test_request_context():
|
||||||
with app_.test_client() as client:
|
with app_.test_client() as client:
|
||||||
@@ -91,8 +118,8 @@ def test_can_see_sms(
|
|||||||
response = client.get(url_for(
|
response = client.get(url_for(
|
||||||
'main.view_notifications',
|
'main.view_notifications',
|
||||||
service_id=service_one['id'],
|
service_id=service_one['id'],
|
||||||
message_type='sms',
|
message_type=message_type,
|
||||||
status='delivered,failed'))
|
status=status_argument))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.get_data(as_text=True)
|
content = response.get_data(as_text=True)
|
||||||
|
|
||||||
@@ -103,9 +130,15 @@ def test_can_see_sms(
|
|||||||
assert notification['template']['name'] in content
|
assert notification['template']['name'] in content
|
||||||
assert 'csv' in content
|
assert 'csv' in content
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
assert page.h1.text.strip() == 'Text messages'
|
assert page_title in page.h1.text.strip()
|
||||||
|
|
||||||
mock_get_notifications.assert_called_with(limit_days=7, page=1, service_id=service_one['id'], status=['delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure'], template_type=['sms']) # noqa
|
mock_get_notifications.assert_called_with(
|
||||||
|
limit_days=7,
|
||||||
|
page=1,
|
||||||
|
service_id=service_one['id'],
|
||||||
|
status=expected_api_call,
|
||||||
|
template_type=[message_type]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_can_see_emails(
|
def test_can_see_emails(
|
||||||
|
|||||||
Reference in New Issue
Block a user