From 94aea8a820e1f16891c9ab5ea57c17adf92050e3 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 19 Jan 2021 15:28:08 +0000 Subject: [PATCH] Add test for when no content or template provided This is the missing invalid permutation of fields for creating a broadcast. --- tests/app/broadcast_message/test_rest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/app/broadcast_message/test_rest.py b/tests/app/broadcast_message/test_rest.py index 83811b42c..30bdc60a3 100644 --- a/tests/app/broadcast_message/test_rest.py +++ b/tests/app/broadcast_message/test_rest.py @@ -280,6 +280,26 @@ def test_create_broadcast_message_400s_if_reference_not_provided_with_content( ) +def test_create_broadcast_message_400s_if_no_content_or_template( + admin_request, + sample_broadcast_service, +): + response = admin_request.post( + 'broadcast_message.create_broadcast_message', + _data={ + 'service_id': str(sample_broadcast_service.id), + 'created_by': str(sample_broadcast_service.created_by_id), + }, + service_id=sample_broadcast_service.id, + _expected_status=400 + ) + assert len(response['errors']) == 1 + assert response['errors'][0]['error'] == 'ValidationError' + assert response['errors'][0]['message'].endswith( + 'is not valid under any of the given schemas' + ) + + @pytest.mark.parametrize('status', [ BroadcastStatusType.DRAFT, BroadcastStatusType.PENDING_APPROVAL,