From a7d92b9058bc888282232408e16dfdbd33a23494 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Fri, 27 Aug 2021 13:13:04 +0100 Subject: [PATCH] Replace / remove redundant uses of "areas" In one case ("areas=['manchester']") the format was even invalid, but in general the original value of the column is pretty much irrelevant for tests that involve updating it (it's highly unlikely the column would default to the same value as the test data). --- app/broadcast_message/rest.py | 2 +- tests/app/broadcast_message/test_rest.py | 8 +++----- tests/app/celery/test_broadcast_message_tasks.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/broadcast_message/rest.py b/app/broadcast_message/rest.py index 02b734ec2..df814de9a 100644 --- a/app/broadcast_message/rest.py +++ b/app/broadcast_message/rest.py @@ -212,7 +212,7 @@ def update_broadcast_message(service_id, broadcast_message_id): broadcast_message.starts_at = _parse_nullable_datetime(data['starts_at']) if 'finishes_at' in data: broadcast_message.finishes_at = _parse_nullable_datetime(data['finishes_at']) - if 'areas' in areas and 'simple_polygons' in areas: + if 'ids' in areas and 'simple_polygons' in areas: broadcast_message.areas = areas dao_save_object(broadcast_message) diff --git a/tests/app/broadcast_message/test_rest.py b/tests/app/broadcast_message/test_rest.py index cfe6bc3ff..ff08e121d 100644 --- a/tests/app/broadcast_message/test_rest.py +++ b/tests/app/broadcast_message/test_rest.py @@ -449,7 +449,7 @@ def test_update_broadcast_message_doesnt_allow_edits_after_broadcast_goes_live( status ): t = create_template(sample_broadcast_service, BROADCAST_TYPE) - bm = create_broadcast_message(t, areas=['manchester'], status=status) + bm = create_broadcast_message(t, status=status) response = admin_request.post( 'broadcast_message.update_broadcast_message', @@ -658,7 +658,6 @@ def test_update_broadcast_message_status_stores_approved_by_and_approved_at_and_ t, status=BroadcastStatusType.PENDING_APPROVAL, areas={ - "areas": ["london"], "ids": ["london"], "simple_polygons": [[[51.30, 0.7], [51.28, 0.8], [51.25, -0.7]]] } @@ -708,7 +707,7 @@ def test_update_broadcast_message_status_updates_details_but_does_not_queue_task bm = create_broadcast_message( t, status=BroadcastStatusType.PENDING_APPROVAL, - areas={"areas": ["london"], "simple_polygons": [[[51.30, 0.7], [51.28, 0.8], [51.25, -0.7]]]}, + areas={"ids": ["london"], "simple_polygons": [[[51.30, 0.7], [51.28, 0.8], [51.25, -0.7]]]}, stubbed=broadcast_message_stubbed ) approver = create_user(email='approver@gov.uk') @@ -761,7 +760,6 @@ def test_update_broadcast_message_status_creates_event_with_correct_content_if_b content='tailor made emergency broadcast content', status=BroadcastStatusType.PENDING_APPROVAL, areas={ - "areas": ["london"], "ids": ["london"], "simple_polygons": [[[51.30, 0.7], [51.28, 0.8], [51.25, -0.7]]] } @@ -849,7 +847,7 @@ def test_update_broadcast_message_status_allows_trial_mode_services_to_approve_o bm = create_broadcast_message( t, status=BroadcastStatusType.PENDING_APPROVAL, - areas={"areas": ["london"], "simple_polygons": [[[51.30, 0.7], [51.28, 0.8], [51.25, -0.7]]]} + areas={"ids": ["london"], "simple_polygons": [[[51.30, 0.7], [51.28, 0.8], [51.25, -0.7]]]} ) mock_task = mocker.patch('app.celery.broadcast_message_tasks.send_broadcast_event.apply_async') diff --git a/tests/app/celery/test_broadcast_message_tasks.py b/tests/app/celery/test_broadcast_message_tasks.py index fce2d2e91..e10f6cbf8 100644 --- a/tests/app/celery/test_broadcast_message_tasks.py +++ b/tests/app/celery/test_broadcast_message_tasks.py @@ -100,7 +100,7 @@ def test_send_broadcast_event_creates_zendesk_p1(mocker, notify_api, sample_broa broadcast_message = create_broadcast_message( template, status=BroadcastStatusType.BROADCASTING, - areas={'areas': ['wd20-S13002775', 'wd20-S13002773'], 'simple_polygons': []}, + areas={'ids': ['wd20-S13002775', 'wd20-S13002773'], 'simple_polygons': []}, ) event = create_broadcast_event(broadcast_message) mock_create_ticket = mocker.patch("app.celery.broadcast_message_tasks.zendesk_client.create_ticket")