2021-01-27 14:32:35 +00:00
|
|
|
import pytest
|
|
|
|
|
|
Show how a broadcast will overspill selected area
Broadcasting is not a precise technology, because:
- cell towers are directional
- their range varies depending on whether they are 2, 3, 4, or 5G
(the higher the bandwidth the shorter the range)
- in urban areas the towers are more densely packed, so a phone is
likely to have a greater choice of tower to connect to, and will
favour a closer one (which has a stronger signal)
- topography and even weather can affect the range of a tower
So it’s good for us to visually indicate that the broadcast is not as
precise as the boundaries of the area, because it gives the person
sending the message an indication of how the technology works.
At the same time we have a restriction on the number of polygons we
think and area can have, so we’ve done some work to make versions of
polygons which are simplified and buffered (see
https://github.com/alphagov/notifications-utils/pull/769 for context).
Serendipitously, the simplified and buffered polygons are larger and
smoother than the detailed polygons we’ve got from the GeoJSON files. So
they naturally give the impression of covering an area which is wider
and less precise.
So this commit takes those simple polygons and uses them to render the
blue fill. This makes the blue fill extend outside the black stroke,
which is still using the detailed polygons direct from the GeoJSON.
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',
|
Show how a broadcast will overspill selected area
Broadcasting is not a precise technology, because:
- cell towers are directional
- their range varies depending on whether they are 2, 3, 4, or 5G
(the higher the bandwidth the shorter the range)
- in urban areas the towers are more densely packed, so a phone is
likely to have a greater choice of tower to connect to, and will
favour a closer one (which has a stronger signal)
- topography and even weather can affect the range of a tower
So it’s good for us to visually indicate that the broadcast is not as
precise as the boundaries of the area, because it gives the person
sending the message an indication of how the technology works.
At the same time we have a restriction on the number of polygons we
think and area can have, so we’ve done some work to make versions of
polygons which are simplified and buffered (see
https://github.com/alphagov/notifications-utils/pull/769 for context).
Serendipitously, the simplified and buffered polygons are larger and
smoother than the detailed polygons we’ve got from the GeoJSON files. So
they naturally give the impression of covering an area which is wider
and less precise.
So this commit takes those simple polygons and uses them to render the
blue fill. This makes the blue fill extend outside the black stroke,
which is still using the detailed polygons direct from the GeoJSON.
2020-08-06 13:38:15 +01:00
|
|
|
# Hackney Wick
|
2020-08-13 12:25:22 +01:00
|
|
|
'wd20-E05009374',
|
Show how a broadcast will overspill selected area
Broadcasting is not a precise technology, because:
- cell towers are directional
- their range varies depending on whether they are 2, 3, 4, or 5G
(the higher the bandwidth the shorter the range)
- in urban areas the towers are more densely packed, so a phone is
likely to have a greater choice of tower to connect to, and will
favour a closer one (which has a stronger signal)
- topography and even weather can affect the range of a tower
So it’s good for us to visually indicate that the broadcast is not as
precise as the boundaries of the area, because it gives the person
sending the message an indication of how the technology works.
At the same time we have a restriction on the number of polygons we
think and area can have, so we’ve done some work to make versions of
polygons which are simplified and buffered (see
https://github.com/alphagov/notifications-utils/pull/769 for context).
Serendipitously, the simplified and buffered polygons are larger and
smoother than the detailed polygons we’ve got from the GeoJSON files. So
they naturally give the impression of covering an area which is wider
and less precise.
So this commit takes those simple polygons and uses them to render the
blue fill. This makes the blue fill extend outside the black stroke,
which is still using the detailed polygons direct from the GeoJSON.
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
|
|
|
|
|
],
|
Show how a broadcast will overspill selected area
Broadcasting is not a precise technology, because:
- cell towers are directional
- their range varies depending on whether they are 2, 3, 4, or 5G
(the higher the bandwidth the shorter the range)
- in urban areas the towers are more densely packed, so a phone is
likely to have a greater choice of tower to connect to, and will
favour a closer one (which has a stronger signal)
- topography and even weather can affect the range of a tower
So it’s good for us to visually indicate that the broadcast is not as
precise as the boundaries of the area, because it gives the person
sending the message an indication of how the technology works.
At the same time we have a restriction on the number of polygons we
think and area can have, so we’ve done some work to make versions of
polygons which are simplified and buffered (see
https://github.com/alphagov/notifications-utils/pull/769 for context).
Serendipitously, the simplified and buffered polygons are larger and
smoother than the detailed polygons we’ve got from the GeoJSON files. So
they naturally give the impression of covering an area which is wider
and less precise.
So this commit takes those simple polygons and uses them to render the
blue fill. This makes the blue fill extend outside the black stroke,
which is still using the detailed polygons direct from the GeoJSON.
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
|
2021-06-24 12:27:12 +01:00
|
|
|
[54],
|
Show how a broadcast will overspill selected area
Broadcasting is not a precise technology, because:
- cell towers are directional
- their range varies depending on whether they are 2, 3, 4, or 5G
(the higher the bandwidth the shorter the range)
- in urban areas the towers are more densely packed, so a phone is
likely to have a greater choice of tower to connect to, and will
favour a closer one (which has a stronger signal)
- topography and even weather can affect the range of a tower
So it’s good for us to visually indicate that the broadcast is not as
precise as the boundaries of the area, because it gives the person
sending the message an indication of how the technology works.
At the same time we have a restriction on the number of polygons we
think and area can have, so we’ve done some work to make versions of
polygons which are simplified and buffered (see
https://github.com/alphagov/notifications-utils/pull/769 for context).
Serendipitously, the simplified and buffered polygons are larger and
smoother than the detailed polygons we’ve got from the GeoJSON files. So
they naturally give the impression of covering an area which is wider
and less precise.
So this commit takes those simple polygons and uses them to render the
blue fill. This makes the blue fill extend outside the black stroke,
which is still using the detailed polygons direct from the GeoJSON.
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'
|
2021-01-27 14:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_raises_for_missing_areas(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=[
|
|
|
|
|
'wd20-E05009372',
|
|
|
|
|
'something else',
|
|
|
|
|
],
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
with pytest.raises(RuntimeError) as exception:
|
|
|
|
|
broadcast_message.areas
|
|
|
|
|
|
|
|
|
|
assert str(exception.value) == (
|
|
|
|
|
'BroadcastMessage has 2 areas but 1 found in the library'
|
|
|
|
|
)
|