mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Revert "Merge pull request #1336 from alphagov/revert-show-notifications"
This reverts commit7e354ff341, reversing changes made to6f3bcff32f.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
from freezegun import freeze_time
|
||||
import pytest
|
||||
from werkzeug.datastructures import MultiDict
|
||||
|
||||
from app.main.views.notifications import get_status_arg
|
||||
from app.utils import (
|
||||
REQUESTED_STATUSES,
|
||||
FAILURE_STATUSES,
|
||||
@@ -10,63 +8,34 @@ from app.utils import (
|
||||
DELIVERED_STATUSES,
|
||||
)
|
||||
|
||||
from tests.app.test_utils import normalize_spaces
|
||||
from tests.conftest import mock_get_notification
|
||||
|
||||
|
||||
@pytest.mark.parametrize('multidict_args, expected_statuses', [
|
||||
([], REQUESTED_STATUSES),
|
||||
([('status', '')], REQUESTED_STATUSES),
|
||||
([('status', 'garbage')], REQUESTED_STATUSES),
|
||||
([('status', 'sending')], SENDING_STATUSES),
|
||||
([('status', 'delivered')], DELIVERED_STATUSES),
|
||||
([('status', 'failed')], FAILURE_STATUSES),
|
||||
@pytest.mark.parametrize('notification_status, expected_status', [
|
||||
('created', 'Sending'),
|
||||
('sending', 'Sending'),
|
||||
('delivered', 'Delivered'),
|
||||
('failed', 'Failed'),
|
||||
('temporary-failure', 'Phone not accepting messages right now'),
|
||||
('permanent-failure', 'Phone number doesn’t exist'),
|
||||
('technical-failure', 'Technical failure'),
|
||||
])
|
||||
def test_status_filters(mocker, multidict_args, expected_statuses):
|
||||
mocker.patch('app.main.views.notifications.current_app')
|
||||
|
||||
args = MultiDict(multidict_args)
|
||||
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',
|
||||
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
|
||||
expected_status,
|
||||
):
|
||||
mock_get_notification(mocker, fake_uuid, notification_status=notification_status)
|
||||
|
||||
_mock_get_notification = mock_get_notification(
|
||||
mocker,
|
||||
fake_uuid,
|
||||
notification_status=notification_status
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_notification',
|
||||
@@ -74,5 +43,17 @@ def test_notification_status_page_shows_correct_numbers(
|
||||
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]
|
||||
assert normalize_spaces(page.select('.sms-message-recipient')[0].text) == (
|
||||
'To: 07123456789'
|
||||
)
|
||||
assert normalize_spaces(page.select('.sms-message-wrapper')[0].text) == (
|
||||
'service one: hello Jo'
|
||||
)
|
||||
assert normalize_spaces(page.select('.ajax-block-container p')[0].text) == (
|
||||
expected_status
|
||||
)
|
||||
|
||||
_mock_get_notification.assert_called_with(
|
||||
service_one['id'],
|
||||
fake_uuid
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user