2017-06-16 12:13:21 +01:00
|
|
|
|
from freezegun import freeze_time
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
from app.utils import (
|
|
|
|
|
|
REQUESTED_STATUSES,
|
|
|
|
|
|
FAILURE_STATUSES,
|
|
|
|
|
|
SENDING_STATUSES,
|
|
|
|
|
|
DELIVERED_STATUSES,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2017-06-24 17:12:45 +01:00
|
|
|
|
from tests.app.test_utils import normalize_spaces
|
2017-06-16 14:57:48 +01:00
|
|
|
|
from tests.conftest import mock_get_notification
|
|
|
|
|
|
|
2017-06-16 12:13:21 +01:00
|
|
|
|
|
2017-06-24 17:12:45 +01:00
|
|
|
|
@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'),
|
2017-06-19 14:37:16 +01:00
|
|
|
|
])
|
2017-06-16 14:57:48 +01:00
|
|
|
|
@freeze_time("2016-01-01 11:09:00.061258")
|
|
|
|
|
|
def test_notification_status_page_shows_details(
|
|
|
|
|
|
client_request,
|
2017-06-24 17:12:45 +01:00
|
|
|
|
mocker,
|
2017-06-16 14:57:48 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
2017-06-24 17:12:45 +01:00
|
|
|
|
notification_status,
|
|
|
|
|
|
expected_status,
|
2017-06-16 14:57:48 +01:00
|
|
|
|
):
|
2017-06-24 17:12:45 +01:00
|
|
|
|
|
|
|
|
|
|
_mock_get_notification = mock_get_notification(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
notification_status=notification_status
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2017-06-16 14:57:48 +01:00
|
|
|
|
page = client_request.get(
|
|
|
|
|
|
'main.view_notification',
|
2017-06-19 12:31:14 +01:00
|
|
|
|
service_id=service_one['id'],
|
|
|
|
|
|
notification_id=fake_uuid
|
2017-06-16 14:57:48 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2017-06-24 17:12:45 +01:00
|
|
|
|
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
|
|
|
|
|
|
)
|
2017-06-16 14:57:48 +01:00
|
|
|
|
|
2017-06-24 17:12:45 +01:00
|
|
|
|
_mock_get_notification.assert_called_with(
|
2017-06-16 14:57:48 +01:00
|
|
|
|
service_one['id'],
|
|
|
|
|
|
fake_uuid
|
|
|
|
|
|
)
|
2017-06-24 17:29:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('template_redaction_setting, expected_content', [
|
|
|
|
|
|
(False, 'service one: hello Jo'),
|
|
|
|
|
|
(True, 'service one: hello hidden'),
|
|
|
|
|
|
])
|
|
|
|
|
|
@freeze_time("2016-01-01 11:09:00.061258")
|
|
|
|
|
|
def test_notification_status_page_respects_redaction(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
template_redaction_setting,
|
|
|
|
|
|
expected_content,
|
|
|
|
|
|
):
|
|
|
|
|
|
|
|
|
|
|
|
_mock_get_notification = mock_get_notification(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
redact_personalisation=template_redaction_setting,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
page = client_request.get(
|
|
|
|
|
|
'main.view_notification',
|
|
|
|
|
|
service_id=service_one['id'],
|
|
|
|
|
|
notification_id=fake_uuid
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert normalize_spaces(page.select('.sms-message-wrapper')[0].text) == expected_content
|
|
|
|
|
|
|
|
|
|
|
|
_mock_get_notification.assert_called_with(
|
|
|
|
|
|
service_one['id'],
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
)
|