mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-14 02:09:44 -04:00
Refactor conversation test to not re-request page
There’s no need to request the page once for each message on it. Quicker to load the page once and then loop through the messages. Still need this as an integration test because it’s testing the ordering and threading of the message.
This commit is contained in:
@@ -70,60 +70,6 @@ def test_get_user_phone_number_raises_if_both_API_requests_fail(
|
||||
mock_get_notification.assert_called_once_with('service', 'notification')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('index, expected', enumerate([
|
||||
(
|
||||
'message-8',
|
||||
'Failed (sent yesterday at 2:59pm)',
|
||||
),
|
||||
(
|
||||
'message-7',
|
||||
'Failed (sent yesterday at 2:59pm)',
|
||||
),
|
||||
(
|
||||
'message-6',
|
||||
'Failed (sent yesterday at 4:59pm)',
|
||||
),
|
||||
(
|
||||
'message-5',
|
||||
'Failed (sent yesterday at 6:59pm)',
|
||||
),
|
||||
(
|
||||
'message-4',
|
||||
'Failed (sent yesterday at 8:59pm)',
|
||||
),
|
||||
(
|
||||
'message-3',
|
||||
'Failed (sent yesterday at 10:59pm)',
|
||||
),
|
||||
(
|
||||
'message-2',
|
||||
'Failed (sent yesterday at 10:59pm)',
|
||||
),
|
||||
(
|
||||
'message-1',
|
||||
'Failed (sent yesterday at 11:00pm)',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
]))
|
||||
@freeze_time("2012-01-01 00:00:00")
|
||||
def test_view_conversation(
|
||||
logged_in_client,
|
||||
@@ -131,8 +77,6 @@ def test_view_conversation(
|
||||
mock_get_notification,
|
||||
mock_get_inbound_sms,
|
||||
mock_get_notifications,
|
||||
index,
|
||||
expected,
|
||||
):
|
||||
|
||||
response = logged_in_client.get(url_for(
|
||||
@@ -148,7 +92,62 @@ def test_view_conversation(
|
||||
|
||||
assert len(messages) == 13
|
||||
assert len(statuses) == 13
|
||||
assert (
|
||||
normalize_spaces(messages[index].text),
|
||||
normalize_spaces(statuses[index].text),
|
||||
) == expected
|
||||
|
||||
for index, expected in enumerate([
|
||||
(
|
||||
'message-8',
|
||||
'Failed (sent yesterday at 2:59pm)',
|
||||
),
|
||||
(
|
||||
'message-7',
|
||||
'Failed (sent yesterday at 2:59pm)',
|
||||
),
|
||||
(
|
||||
'message-6',
|
||||
'Failed (sent yesterday at 4:59pm)',
|
||||
),
|
||||
(
|
||||
'message-5',
|
||||
'Failed (sent yesterday at 6:59pm)',
|
||||
),
|
||||
(
|
||||
'message-4',
|
||||
'Failed (sent yesterday at 8:59pm)',
|
||||
),
|
||||
(
|
||||
'message-3',
|
||||
'Failed (sent yesterday at 10:59pm)',
|
||||
),
|
||||
(
|
||||
'message-2',
|
||||
'Failed (sent yesterday at 10:59pm)',
|
||||
),
|
||||
(
|
||||
'message-1',
|
||||
'Failed (sent yesterday at 11:00pm)',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
(
|
||||
'template content',
|
||||
'yesterday at midnight',
|
||||
),
|
||||
]):
|
||||
assert (
|
||||
normalize_spaces(messages[index].text),
|
||||
normalize_spaces(statuses[index].text),
|
||||
) == expected
|
||||
|
||||
Reference in New Issue
Block a user