mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
reading messages for inbox from new most_recent endpoint
avoids us having to work out and display most recent messages only on the front-end - it's now all done in api
This commit is contained in:
@@ -180,7 +180,7 @@ def test_inbox_showing_inbound_messages(
|
||||
mock_get_detailed_service,
|
||||
mock_get_template_statistics,
|
||||
mock_get_usage,
|
||||
mock_get_inbound_sms,
|
||||
mock_get_most_recent_inbound_sms,
|
||||
index,
|
||||
expected_row,
|
||||
):
|
||||
@@ -208,7 +208,7 @@ def test_get_inbound_sms_shows_page_links(
|
||||
mock_get_detailed_service,
|
||||
mock_get_template_statistics,
|
||||
mock_get_usage,
|
||||
mock_get_inbound_sms,
|
||||
mock_get_most_recent_inbound_sms,
|
||||
mock_get_inbound_number_for_service,
|
||||
):
|
||||
service_one['permissions'] = ['inbound_sms']
|
||||
@@ -229,7 +229,7 @@ def test_empty_inbox(
|
||||
mock_get_detailed_service,
|
||||
mock_get_template_statistics,
|
||||
mock_get_usage,
|
||||
mock_get_inbound_sms_with_no_messages,
|
||||
mock_get_most_recent_inbound_sms_with_no_messages,
|
||||
mock_get_inbound_number_for_service,
|
||||
):
|
||||
|
||||
@@ -267,7 +267,7 @@ def test_anyone_can_see_inbox(
|
||||
api_user_active,
|
||||
service_one,
|
||||
mocker,
|
||||
mock_get_inbound_sms_with_no_messages,
|
||||
mock_get_most_recent_inbound_sms_with_no_messages,
|
||||
mock_get_inbound_number_for_service,
|
||||
):
|
||||
|
||||
@@ -289,7 +289,7 @@ def test_view_inbox_updates(
|
||||
logged_in_client,
|
||||
service_one,
|
||||
mocker,
|
||||
mock_get_inbound_sms_with_no_messages,
|
||||
mock_get_most_recent_inbound_sms_with_no_messages,
|
||||
):
|
||||
|
||||
mock_get_partials = mocker.patch(
|
||||
|
||||
@@ -1882,8 +1882,32 @@ def mock_get_inbound_sms(mocker):
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_inbound_sms_with_no_messages(mocker):
|
||||
def _get_inbound_sms(
|
||||
def mock_get_most_recent_inbound_sms(mocker):
|
||||
def _get_most_recent_inbound_sms(
|
||||
service_id,
|
||||
user_number=None,
|
||||
page=1
|
||||
):
|
||||
return {
|
||||
'has_next': True,
|
||||
'data': [{
|
||||
'user_number': '0790090000' + str(i),
|
||||
'notify_number': '07900000002',
|
||||
'content': 'message-{}'.format(index + 1),
|
||||
'created_at': (datetime.utcnow() - timedelta(minutes=60 * (i + 1), seconds=index)).isoformat(),
|
||||
'id': sample_uuid(),
|
||||
} for index, i in enumerate([0, 0, 0, 2, 4, 6, 8, 8])]
|
||||
}
|
||||
|
||||
return mocker.patch(
|
||||
'app.service_api_client.get_most_recent_inbound_sms',
|
||||
side_effect=_get_most_recent_inbound_sms,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_most_recent_inbound_sms_with_no_messages(mocker):
|
||||
def _get_most_recent_inbound_sms(
|
||||
service_id,
|
||||
user_number=None,
|
||||
page=1
|
||||
@@ -1894,8 +1918,8 @@ def mock_get_inbound_sms_with_no_messages(mocker):
|
||||
}
|
||||
|
||||
return mocker.patch(
|
||||
'app.service_api_client.get_inbound_sms',
|
||||
side_effect=_get_inbound_sms,
|
||||
'app.service_api_client.get_most_recent_inbound_sms',
|
||||
side_effect=_get_most_recent_inbound_sms,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user