Files
notifications-admin/tests/app/main/test_formatters.py
Chris Hill-Scott 3c6598cbc2 Only link to message status if message has failed
This retores the behaviour to as it was before
https://github.com/alphagov/notifications-admin/pull/2962
which inadvertently started linking to the guidance for messages that
were delivered or in sending.
2019-05-13 13:29:47 +01:00

36 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from functools import partial
import pytest
from flask import url_for
from app import format_notification_status_as_url
@pytest.mark.parametrize('status, notification_type, expected', (
# Successful statuses arent linked
('created', 'email', lambda: None),
('sending', 'email', lambda: None),
('delivered', 'email', lambda: None),
# Failures are linked to the channel-specific page
('temporary-failure', 'email', partial(url_for, 'main.message_status', _anchor='email-statuses')),
('permanent-failure', 'email', partial(url_for, 'main.message_status', _anchor='email-statuses')),
('technical-failure', 'email', partial(url_for, 'main.message_status', _anchor='email-statuses')),
('temporary-failure', 'sms', partial(url_for, 'main.message_status', _anchor='sms-statuses')),
('permanent-failure', 'sms', partial(url_for, 'main.message_status', _anchor='sms-statuses')),
('technical-failure', 'sms', partial(url_for, 'main.message_status', _anchor='sms-statuses')),
# Letter statuses are never linked
('technical-failure', 'letter', lambda: None),
('cancelled', 'letter', lambda: None),
('accepted', 'letter', lambda: None),
('received', 'letter', lambda: None),
))
def test_format_notification_status_as_url(
client,
status,
notification_type,
expected,
):
assert format_notification_status_as_url(
status, notification_type
) == expected()