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:
chrisw
2018-04-04 15:57:31 +01:00
parent 1d32c766e8
commit 78d16709d6
4 changed files with 44 additions and 10 deletions

View File

@@ -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,
)