mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-25 08:43:55 -04:00
Stop defaulting "ids" to an empty array
This is so we can distinguish custom broadcasts in the Admin app
[1]. I've also extended the POST test for custom broadcasts to
check we're correctly reading data for "names", as this wasn't
being tested previously.
[1]: 411fda81c0
This commit is contained in:
@@ -2338,7 +2338,6 @@ class BroadcastMessage(db.Model):
|
|||||||
def serialize(self):
|
def serialize(self):
|
||||||
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.get("ids", [])
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': str(self.id),
|
'id': str(self.id),
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ def test_create_broadcast_message(admin_request, sample_broadcast_service, train
|
|||||||
assert response['created_at'] is not None
|
assert response['created_at'] is not None
|
||||||
assert response['created_by_id'] == str(t.created_by_id)
|
assert response['created_by_id'] == str(t.created_by_id)
|
||||||
assert response['personalisation'] == {}
|
assert response['personalisation'] == {}
|
||||||
assert response['areas']['ids'] == []
|
|
||||||
assert response['areas']['simple_polygons'] == []
|
assert response['areas']['simple_polygons'] == []
|
||||||
assert response['content'] == 'Some content\n€ŷŵ~\n\'\'""---'
|
assert response['content'] == 'Some content\n€ŷŵ~\n\'\'""---'
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ def test_valid_post_cap_xml_broadcast_returns_201(
|
|||||||
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']['names'] == ['River Steeping in Wainfleet All Saints']
|
||||||
|
assert 'ids' not in response_json['areas'] # only for broadcasts created in Admin
|
||||||
|
|
||||||
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