From c9afb2f03811f9e4189145920b942c8b9c67ac1c Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Wed, 19 Jan 2022 16:17:06 +0000 Subject: [PATCH] Remove unnecessary error handling The context here should be enough for the users, custom error message is not needed. --- app/v2/broadcast/post_broadcast.py | 15 ++++----------- tests/app/v2/broadcast/test_post_broadcast.py | 3 --- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/v2/broadcast/post_broadcast.py b/app/v2/broadcast/post_broadcast.py index 165935b54..6d6518cfc 100644 --- a/app/v2/broadcast/post_broadcast.py +++ b/app/v2/broadcast/post_broadcast.py @@ -101,17 +101,10 @@ def create_broadcast(): def _cancel_or_reject_broadcast(references_to_original_broadcast, service_id): - try: - broadcast_message = dao_get_broadcast_message_by_references_and_service_id( - references_to_original_broadcast, - service_id - ) - except NoResultFound: - raise BadRequestError( - message="Broadcast message reference and service id didn't match with any existing broadcasts", - status_code=404, - ) - + broadcast_message = dao_get_broadcast_message_by_references_and_service_id( + references_to_original_broadcast, + service_id + ) if broadcast_message.status == BroadcastStatusType.PENDING_APPROVAL: new_status = BroadcastStatusType.REJECTED else: diff --git a/tests/app/v2/broadcast/test_post_broadcast.py b/tests/app/v2/broadcast/test_post_broadcast.py index f4a5e25c3..de88ac1c8 100644 --- a/tests/app/v2/broadcast/test_post_broadcast.py +++ b/tests/app/v2/broadcast/test_post_broadcast.py @@ -234,9 +234,6 @@ def test_cancel_request_does_not_cancel_broadcast_if_reference_does_not_match( ) assert response_for_cancel.status_code == 404 - response = json.loads(response_for_cancel.get_data(as_text=True)) - expected_error_message = "Broadcast message reference and service id didn't match with any existing broadcasts" - assert response["errors"][0]["message"] == expected_error_message def test_large_polygon_is_simplified(