Fix serialisation of callbacks

Because the IDs of our callback and inbound SMS APIs were stored in
lists instead of directly on the serialised model they weren’t getting
cast to a string before trying to JSONify them. And JSON doesn’t know
what to do with a UUID object.

For some reason this was only affecting the endpoint for fetching
inbound SMS.
This commit is contained in:
Chris Hill-Scott
2020-06-26 16:31:49 +01:00
parent 8cef34d770
commit 8def7d0d3b
2 changed files with 29 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
from flask import json, url_for
from tests import create_authorization_header
from tests.app.db import create_inbound_sms
from tests.app.db import create_inbound_sms, create_service_inbound_api, create_service_callback_api
def test_get_inbound_sms_returns_200(
@@ -31,6 +31,27 @@ def test_get_inbound_sms_returns_200(
assert json_response == expected_response
def test_get_inbound_sms_returns_200_when_service_has_callbacks(
client, sample_service
):
create_service_inbound_api(
service=sample_service,
url="https://inbound.example.com",
)
create_service_callback_api(
service=sample_service,
url="https://inbound.example.com",
)
auth_header = create_authorization_header(service_id=sample_service.id)
response = client.get(
path='/v2/received-text-messages',
headers=[('Content-Type', 'application/json'), auth_header],
)
assert response.status_code == 200
def test_get_inbound_sms_generate_page_links(client, sample_service, mocker):
mocker.patch.dict(
"app.v2.inbound_sms.get_inbound_sms.current_app.config",