mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
Support new broadcasts (without area IDs)
Previously we relied on the API defaulting this field to an empty
array [1], but that conflicts with using it to decide whether a
broadcast is custom or created in this app.
[1]: 3779146cc5/app/models.py (L2342)
This commit is contained in:
@@ -111,7 +111,7 @@ class BroadcastMessage(JSONModel):
|
||||
|
||||
@property
|
||||
def area_ids(self):
|
||||
return self._dict['areas']['ids']
|
||||
return self._dict['areas'].get('ids', [])
|
||||
|
||||
@area_ids.setter
|
||||
def area_ids(self, value):
|
||||
|
||||
@@ -4,6 +4,21 @@ from app.models.broadcast_message import BroadcastMessage
|
||||
from tests import broadcast_message_json
|
||||
|
||||
|
||||
@pytest.mark.parametrize('areas, expected_area_ids', [
|
||||
({'simple_polygons': []}, []),
|
||||
({'ids': ['123'], 'simple_polygons': []}, ['123'])
|
||||
])
|
||||
def test_area_ids(
|
||||
areas,
|
||||
expected_area_ids,
|
||||
):
|
||||
broadcast_message = BroadcastMessage(broadcast_message_json(
|
||||
areas=areas
|
||||
))
|
||||
|
||||
assert broadcast_message.area_ids == expected_area_ids
|
||||
|
||||
|
||||
def test_simple_polygons():
|
||||
broadcast_message = BroadcastMessage(broadcast_message_json(
|
||||
area_ids=[
|
||||
|
||||
Reference in New Issue
Block a user