mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Support custom broadcasts (without area IDs)
Custom broadcasts created directly via the API app won't have area
IDs since [1], where we started to distinguish between "names" (all
broadcasts have these) and IDs (for broadcasts created in this app).
We forgot to propagate the distinction into the code here.
This code fixes the bug for all broadcasts created after [1]. Any
custom broadcasts created before [1] will have their "ids" field set
instead of "names" so we won't show anything for them. This seems
reasonable as we don't support custom broadcasts yet.
[1]: 023a06d5fb
This commit is contained in:
@@ -38,6 +38,22 @@ def test_content_comes_from_attribute_not_template():
|
||||
assert broadcast_message.content == 'This is a test'
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('areas', 'expected_length'), [
|
||||
({'ids': []}, 0),
|
||||
({'ids': ['wd20-E05009372']}, 1),
|
||||
({'names': ['somewhere'], 'simple_polygons': [[[3.5, 1.5]]]}, 1)
|
||||
])
|
||||
def test_areas(
|
||||
areas,
|
||||
expected_length
|
||||
):
|
||||
broadcast_message = BroadcastMessage(broadcast_message_json(
|
||||
areas=areas
|
||||
))
|
||||
|
||||
assert len(list(broadcast_message.areas)) == expected_length
|
||||
|
||||
|
||||
def test_areas_raises_for_missing_areas():
|
||||
broadcast_message = BroadcastMessage(broadcast_message_json(
|
||||
area_ids=[
|
||||
|
||||
Reference in New Issue
Block a user