mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 02:23:32 -04:00
Remove support for old "areas" sub-field
All broadcasts with this field have now been migrated to use "ids". This also removes a few lines that were missed in previous PRs: - Added by mistake: https://github.com/alphagov/notifications-api/commit/fd7ebbebb053318a0e1bb89b2445fe385f82583c#diff-045554136e1462693a6cbb6328b2e056a81e8b348e94575edd8f72b78c5da96eR115 - Missed removal: https://github.com/alphagov/notifications-api/commit/ec1171f85cfac62318de9e69b0ee8a39b9c05949#diff-045554136e1462693a6cbb6328b2e056a81e8b348e94575edd8f72b78c5da96eR110
This commit is contained in:
+1
-2
@@ -2336,10 +2336,9 @@ class BroadcastMessage(db.Model):
|
|||||||
self._personalisation = encryption.encrypt(personalisation or {})
|
self._personalisation = encryption.encrypt(personalisation or {})
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
# TEMPORARY: while we repurpose "areas"
|
|
||||||
areas = dict(self.areas)
|
areas = dict(self.areas)
|
||||||
areas["simple_polygons"] = areas.get("simple_polygons", [])
|
areas["simple_polygons"] = areas.get("simple_polygons", [])
|
||||||
areas["ids"] = areas.pop("areas", areas.get("ids", []))
|
areas["ids"] = areas.get("ids", [])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': str(self.id),
|
'id': str(self.id),
|
||||||
|
|||||||
@@ -19,13 +19,7 @@ from tests.app.db import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# TEMPORARY: while we repurpose "areas"
|
|
||||||
@pytest.mark.parametrize("area_data", [
|
|
||||||
{"areas": ["place A", "region B"]},
|
|
||||||
{"ids": ["place A", "region B"]},
|
|
||||||
])
|
|
||||||
def test_get_broadcast_message(
|
def test_get_broadcast_message(
|
||||||
area_data,
|
|
||||||
admin_request,
|
admin_request,
|
||||||
sample_broadcast_service
|
sample_broadcast_service
|
||||||
):
|
):
|
||||||
@@ -37,7 +31,7 @@ def test_get_broadcast_message(
|
|||||||
bm = create_broadcast_message(
|
bm = create_broadcast_message(
|
||||||
t,
|
t,
|
||||||
areas={
|
areas={
|
||||||
**area_data,
|
"ids": ["place A", "region B"],
|
||||||
"simple_polygons": [[[50.1, 1.2], [50.12, 1.2], [50.13, 1.2]]],
|
"simple_polygons": [[[50.1, 1.2], [50.12, 1.2], [50.13, 1.2]]],
|
||||||
},
|
},
|
||||||
personalisation={
|
personalisation={
|
||||||
@@ -64,13 +58,7 @@ def test_get_broadcast_message(
|
|||||||
assert response['personalisation'] == {'thing': 'test'}
|
assert response['personalisation'] == {'thing': 'test'}
|
||||||
|
|
||||||
|
|
||||||
# TEMPORARY: while we repurpose "areas"
|
|
||||||
@pytest.mark.parametrize("area_data", [
|
|
||||||
{"areas": ["place A", "region B"]},
|
|
||||||
{"ids": ["place A", "region B"]},
|
|
||||||
])
|
|
||||||
def test_get_broadcast_message_without_template(
|
def test_get_broadcast_message_without_template(
|
||||||
area_data,
|
|
||||||
admin_request,
|
admin_request,
|
||||||
sample_broadcast_service
|
sample_broadcast_service
|
||||||
):
|
):
|
||||||
@@ -78,7 +66,7 @@ def test_get_broadcast_message_without_template(
|
|||||||
service=sample_broadcast_service,
|
service=sample_broadcast_service,
|
||||||
content='emergency broadcast content',
|
content='emergency broadcast content',
|
||||||
areas={
|
areas={
|
||||||
**area_data,
|
"ids": ["place A", "region B"],
|
||||||
"simple_polygons": [[[50.1, 1.2], [50.12, 1.2], [50.13, 1.2]]],
|
"simple_polygons": [[[50.1, 1.2], [50.12, 1.2], [50.13, 1.2]]],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -103,12 +103,10 @@ def test_valid_post_cap_xml_broadcast_returns_201(
|
|||||||
assert response_json['personalisation'] is None
|
assert response_json['personalisation'] is None
|
||||||
assert response_json['service_id'] == str(sample_broadcast_service.id)
|
assert response_json['service_id'] == str(sample_broadcast_service.id)
|
||||||
|
|
||||||
# TEMPORARY: while we repurpose "areas"
|
|
||||||
assert len(response_json['areas']['simple_polygons']) == 1
|
assert len(response_json['areas']['simple_polygons']) == 1
|
||||||
assert len(response_json['areas']['simple_polygons'][0]) == 23
|
assert len(response_json['areas']['simple_polygons'][0]) == 23
|
||||||
assert response_json['areas']['simple_polygons'][0][0] == [53.10562, 0.244127]
|
assert response_json['areas']['simple_polygons'][0][0] == [53.10562, 0.244127]
|
||||||
assert response_json['areas']['simple_polygons'][0][-1] == [53.10562, 0.244127]
|
assert response_json['areas']['simple_polygons'][0][-1] == [53.10562, 0.244127]
|
||||||
assert response_json['areas']['simple_polygons'][0][-1] == [53.10562, 0.244127]
|
|
||||||
|
|
||||||
assert response_json['starts_at'] is None
|
assert response_json['starts_at'] is None
|
||||||
assert response_json['status'] == 'pending-approval'
|
assert response_json['status'] == 'pending-approval'
|
||||||
|
|||||||
Reference in New Issue
Block a user