Files
notifications-admin/tests/app/broadcast_areas/test_models.py
Chris Hill-Scott 6cb326f153 Update utils to do linear transformation of polygons
Brings in https://github.com/alphagov/notifications-utils/pull/889/files

At the moment, we are not doing any transformation of features before
applying geometric algorithms to them. This is, in effect, assuming that
the earth is flat.

This new version of utils implements the transformation of our polygons
to a Cartesian plane. In other words, it converts them from being
defined in spherical degrees to metres.

For the admin app this means we need to convert places where the code
expects things to be measured in degrees to work in metres instead.
2021-12-01 14:10:54 +00:00

21 lines
590 B
Python

import pytest
from app.broadcast_areas.models import CustomBroadcastArea
from tests.app.broadcast_areas.custom_polygons import BRISTOL, SANTA_A, SKYE
@pytest.mark.parametrize(('simple_polygon', 'expected_wards_length'), [
(SKYE, 1),
(BRISTOL, 12),
(SANTA_A, 0) # does not overlap with UK
])
def test_custom_broadcast_area_overlapping_electoral_wards(
simple_polygon,
expected_wards_length,
):
custom_area = CustomBroadcastArea(
name='foo', polygons=[simple_polygon]
)
assert len(custom_area.overlapping_electoral_wards) == expected_wards_length