diff --git a/app/schemas.py b/app/schemas.py index 763f34143..6199c14bd 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -63,9 +63,16 @@ class UUIDsAsStringsMixin: @post_dump() def __post_dump(self, data): for key, value in data.items(): + if isinstance(value, UUID): data[key] = str(value) + if isinstance(value, list): + data[key] = [ + (str(item) if isinstance(item, UUID) else item) + for item in value + ] + class BaseSchema(ma.ModelSchema): diff --git a/tests/app/v2/inbound_sms/test_get_inbound_sms.py b/tests/app/v2/inbound_sms/test_get_inbound_sms.py index dfd4ae0b9..7231ed9b9 100644 --- a/tests/app/v2/inbound_sms/test_get_inbound_sms.py +++ b/tests/app/v2/inbound_sms/test_get_inbound_sms.py @@ -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",