2020-08-06 13:38:15 +01:00
|
|
|
from app.models.broadcast_message import BroadcastMessage
|
|
|
|
|
from tests import broadcast_message_json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_simple_polygons(fake_uuid):
|
|
|
|
|
broadcast_message = BroadcastMessage(broadcast_message_json(
|
|
|
|
|
id_=fake_uuid,
|
|
|
|
|
service_id=fake_uuid,
|
|
|
|
|
template_id=fake_uuid,
|
|
|
|
|
status='draft',
|
|
|
|
|
created_by_id=fake_uuid,
|
|
|
|
|
areas=[
|
|
|
|
|
# Hackney Central
|
2020-08-13 12:25:22 +01:00
|
|
|
'wd20-E05009372',
|
2020-08-06 13:38:15 +01:00
|
|
|
# Hackney Wick
|
2020-08-13 12:25:22 +01:00
|
|
|
'wd20-E05009374',
|
2020-08-06 13:38:15 +01:00
|
|
|
],
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
assert [
|
2020-08-25 16:55:09 +01:00
|
|
|
[
|
|
|
|
|
len(polygon)
|
|
|
|
|
for polygon in broadcast_message.polygons.as_coordinate_pairs_lat_long
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
len(polygon)
|
|
|
|
|
for polygon in broadcast_message.simple_polygons.as_coordinate_pairs_lat_long
|
|
|
|
|
],
|
2020-08-06 13:38:15 +01:00
|
|
|
] == [
|
|
|
|
|
# One polygon for each area
|
|
|
|
|
[27, 31],
|
|
|
|
|
# Because the areas are close to each other, the simplification
|
|
|
|
|
# and unioning process results in a single polygon with fewer
|
|
|
|
|
# total coordinates
|
2020-09-24 14:37:28 +01:00
|
|
|
[51],
|
2020-08-06 13:38:15 +01:00
|
|
|
]
|
2020-10-08 14:06:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_content_comes_from_attribute_not_template(fake_uuid):
|
|
|
|
|
broadcast_message = BroadcastMessage(broadcast_message_json(
|
|
|
|
|
id_=fake_uuid,
|
|
|
|
|
service_id=fake_uuid,
|
|
|
|
|
template_id=fake_uuid,
|
|
|
|
|
status='draft',
|
|
|
|
|
created_by_id=fake_uuid,
|
|
|
|
|
))
|
|
|
|
|
assert broadcast_message.content == 'This is a test'
|