From 5b2dee5ddb6b87e8b636d2a4481228703357292a Mon Sep 17 00:00:00 2001 From: David McDonald Date: Mon, 14 Sep 2020 15:21:55 +0100 Subject: [PATCH] Bump utils to 42.0.0 Requires unit test updating as we now expect broadcast event areas to be a dict containing a list of areas and simple polygons. --- app/celery/broadcast_message_tasks.py | 2 +- requirements-app.txt | 2 +- requirements.txt | 10 +++++----- tests/app/broadcast_message/test_rest.py | 2 +- tests/app/celery/test_broadcast_message_tasks.py | 11 ++++++++--- tests/app/db.py | 4 +++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/celery/broadcast_message_tasks.py b/app/celery/broadcast_message_tasks.py index 9539fb7cb..f73705f5a 100644 --- a/app/celery/broadcast_message_tasks.py +++ b/app/celery/broadcast_message_tasks.py @@ -4,7 +4,7 @@ from notifications_utils.statsd_decorators import statsd from app import notify_celery -from app.dao.broadcast_message_dao import dao_get_broadcast_message_by_id, dao_get_broadcast_event_by_id +from app.dao.broadcast_message_dao import dao_get_broadcast_event_by_id @notify_celery.task(name="send-broadcast-event") diff --git a/requirements-app.txt b/requirements-app.txt index 58776861b..16cf4e6f7 100644 --- a/requirements-app.txt +++ b/requirements-app.txt @@ -29,7 +29,7 @@ notifications-python-client==5.7.0 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@41.3.1#egg=notifications-utils==41.3.1 +git+https://github.com/alphagov/notifications-utils.git@42.0.0#egg=notifications-utils==42.0.0 # gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains prometheus-client==0.8.0 diff --git a/requirements.txt b/requirements.txt index 576cf4c87..b6efb7e08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,25 +31,25 @@ notifications-python-client==5.7.0 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@41.3.1#egg=notifications-utils==41.3.1 +git+https://github.com/alphagov/notifications-utils.git@42.0.0#egg=notifications-utils==42.0.0 # gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains prometheus-client==0.8.0 gds-metrics==0.2.4 ## The following requirements were added by pip freeze: -alembic==1.4.2 +alembic==1.4.3 amqp==1.4.9 anyjson==0.3.3 attrs==20.2.0 -awscli==1.18.135 +awscli==1.18.137 bcrypt==3.2.0 billiard==3.3.0.23 bleach==3.1.4 blinker==1.4 boto==2.49.0 boto3==1.10.38 -botocore==1.17.58 +botocore==1.17.60 certifi==2020.6.20 chardet==3.0.4 click==7.1.2 @@ -76,7 +76,7 @@ phonenumbers==8.11.2 pyasn1==0.4.8 pycparser==2.20 PyPDF2==1.26.0 -pyrsistent==0.16.0 +pyrsistent==0.17.3 python-dateutil==2.8.1 python-editor==1.0.4 python-json-logger==0.1.11 diff --git a/tests/app/broadcast_message/test_rest.py b/tests/app/broadcast_message/test_rest.py index c5564df17..ef3e6f031 100644 --- a/tests/app/broadcast_message/test_rest.py +++ b/tests/app/broadcast_message/test_rest.py @@ -154,7 +154,7 @@ def test_update_broadcast_message_allows_edit_while_not_yet_live(admin_request, _data={ 'starts_at': '2020-06-01 20:00:01', 'areas': ['london', 'glasgow'], - "simple_polygons": [[51.12, 0.2], [50.13, 0.4], [50.14, 0.45]] + "simple_polygons": [[[51.12, 0.2], [50.13, 0.4], [50.14, 0.45]]] }, service_id=t.service_id, broadcast_message_id=bm.id, diff --git a/tests/app/celery/test_broadcast_message_tasks.py b/tests/app/celery/test_broadcast_message_tasks.py index 3436dce9b..76d5e2001 100644 --- a/tests/app/celery/test_broadcast_message_tasks.py +++ b/tests/app/celery/test_broadcast_message_tasks.py @@ -3,7 +3,6 @@ import pytest import requests_mock from requests import RequestException -from app.dao.templates_dao import dao_update_template from app.models import BROADCAST_TYPE, BroadcastStatusType, BroadcastEventMessageType from app.celery.broadcast_message_tasks import send_broadcast_event from tests.app.db import create_template, create_broadcast_message, create_broadcast_event @@ -12,7 +11,11 @@ from tests.app.db import create_template, create_broadcast_message, create_broad @freeze_time('2020-08-01 12:00') def test_send_broadcast_event_sends_data_correctly(sample_service): template = create_template(sample_service, BROADCAST_TYPE) - broadcast_message = create_broadcast_message(template, areas=['london'], status=BroadcastStatusType.BROADCASTING) + broadcast_message = create_broadcast_message( + template, + areas={"areas": ['london'], "simple_polygons": [[[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]]]}, + status=BroadcastStatusType.BROADCASTING + ) event = create_broadcast_event(broadcast_message) with requests_mock.Mocker() as request_mock: @@ -28,7 +31,9 @@ def test_send_broadcast_event_sends_data_correctly(sample_service): assert cbc_json['broadcast_message_id'] == str(broadcast_message.id) assert cbc_json['sent_at'] == '2020-08-01T12:00:00.000000Z' assert cbc_json['transmitted_starts_at'] is None - assert cbc_json['transmitted_areas'] == ['london'] + assert cbc_json['transmitted_areas'] == { + "areas": ['london'], "simple_polygons": [[[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]]] + } def test_send_broadcast_event_sends_references(sample_service): diff --git a/tests/app/db.py b/tests/app/db.py index 89e42ec15..4fe5018dd 100644 --- a/tests/app/db.py +++ b/tests/app/db.py @@ -1040,7 +1040,9 @@ def create_broadcast_event( sent_at=sent_at or datetime.utcnow(), message_type=message_type, transmitted_content=transmitted_content or {'body': 'this is an emergency broadcast message'}, - transmitted_areas=transmitted_areas or ['london'], + transmitted_areas=transmitted_areas or { + 'areas': ['london'], 'simple_polygons': [[[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]]] + }, transmitted_sender=transmitted_sender or 'www.notifications.service.gov.uk', transmitted_starts_at=transmitted_starts_at, transmitted_finishes_at=transmitted_finishes_at or datetime.utcnow(),