mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
add tests for notification status page
This commit is contained in:
@@ -10,6 +10,8 @@ from app.utils import (
|
||||
DELIVERED_STATUSES,
|
||||
)
|
||||
|
||||
from tests.conftest import mock_get_notification
|
||||
|
||||
|
||||
@pytest.mark.parametrize('multidict_args, expected_statuses', [
|
||||
([], REQUESTED_STATUSES),
|
||||
@@ -26,3 +28,55 @@ def test_status_filters(mocker, multidict_args, expected_statuses):
|
||||
args['status'] = get_status_arg(args)
|
||||
|
||||
assert sorted(args['status']) == sorted(expected_statuses)
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_notification_status_page_shows_details(
|
||||
client_request,
|
||||
mock_get_notification,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.view_notification',
|
||||
endpoint_kwargs={
|
||||
'service_id': service_one['id'],
|
||||
'notification_id': fake_uuid
|
||||
}
|
||||
)
|
||||
|
||||
assert page.find('div', {'class': 'sms-message-wrapper'}).text.strip() == 'service one: template content'
|
||||
assert ' '.join(page.find('tbody').find('tr').text.split()) == '07123456789 Delivered 1 January at 11:10am'
|
||||
|
||||
mock_get_notification.assert_called_with(
|
||||
service_one['id'],
|
||||
fake_uuid
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('notification_status, expected_big_number_vals', [
|
||||
('created', [1, 1, 0, 0]),
|
||||
('sending', [1, 1, 0, 0]),
|
||||
('delivered', [1, 0, 1, 0]),
|
||||
('temporary-failure', [1, 0, 0, 1]),
|
||||
])
|
||||
def test_notification_status_page_shows_correct_numbers(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
notification_status,
|
||||
expected_big_number_vals
|
||||
):
|
||||
mock_get_notification(mocker, fake_uuid, notification_status=notification_status)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_notification',
|
||||
endpoint_kwargs={
|
||||
'service_id': service_one['id'],
|
||||
'notification_id': fake_uuid
|
||||
}
|
||||
)
|
||||
|
||||
big_numbers = page.find_all('div', {'class': 'big-number-number'})
|
||||
assert expected_big_number_vals == [int(num.text.strip()) for num in big_numbers]
|
||||
|
||||
@@ -33,3 +33,11 @@ def test_client_gets_notifications_for_service_and_job_by_page(mocker, arguments
|
||||
mock_get = mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.get')
|
||||
NotificationApiClient().get_notifications_for_service('abcd1234', **arguments)
|
||||
mock_get.assert_called_once_with(**expected_call)
|
||||
|
||||
|
||||
def test_get_notification(mocker):
|
||||
mock_get = mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.get')
|
||||
NotificationApiClient().get_notification('foo', 'bar')
|
||||
mock_get.assert_called_once_with(
|
||||
url='/service/foo/notifications/bar'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user