mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 04:43:12 -04:00
Rename electoral wards to local areas
We’ve observed people using ‘national’ and ‘local’ during user research. It has less tongue-twisting ambiguity than county vs country. But we think that maybe just getting rid of ‘counties’ is enough to disambiguate them. So this commit just takes the ‘local’ concept. This commit also gives the libraries and areas new IDs, which means if we want to rename them in the future it won’t be a breaking change.
This commit is contained in:
@@ -11,18 +11,18 @@ def test_loads_libraries():
|
||||
(library.id, library.name, library.is_group) for library in sorted(broadcast_area_libraries)
|
||||
] == [
|
||||
(
|
||||
'counties-and-unitary-authorities-in-england-and-wales',
|
||||
'ctyua16',
|
||||
'Counties and Unitary Authorities in England and Wales',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'countries',
|
||||
'ctry19',
|
||||
'Countries',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'electoral-wards-of-the-united-kingdom',
|
||||
'Electoral Wards of the United Kingdom',
|
||||
'wd20-lad20',
|
||||
'Local authorities',
|
||||
True,
|
||||
),
|
||||
]
|
||||
@@ -31,41 +31,41 @@ def test_loads_libraries():
|
||||
def test_loads_areas_from_library():
|
||||
assert [
|
||||
(area.id, area.name) for area in sorted(
|
||||
broadcast_area_libraries.get('countries')
|
||||
broadcast_area_libraries.get('ctry19')
|
||||
)
|
||||
] == [
|
||||
('countries-E92000001', 'England'),
|
||||
('countries-N92000002', 'Northern Ireland'),
|
||||
('countries-S92000003', 'Scotland'),
|
||||
('countries-W92000004', 'Wales'),
|
||||
('ctry19-E92000001', 'England'),
|
||||
('ctry19-N92000002', 'Northern Ireland'),
|
||||
('ctry19-S92000003', 'Scotland'),
|
||||
('ctry19-W92000004', 'Wales'),
|
||||
]
|
||||
|
||||
|
||||
def test_examples():
|
||||
countries = broadcast_area_libraries.get('countries').get_examples()
|
||||
countries = broadcast_area_libraries.get('ctry19').get_examples()
|
||||
assert countries == 'England, Northern Ireland, Scotland, and Wales'
|
||||
|
||||
counties = broadcast_area_libraries.get(
|
||||
'counties-and-unitary-authorities-in-england-and-wales',
|
||||
'ctyua16',
|
||||
).get_examples()
|
||||
assert counties == 'Barking and Dagenham, Barnet, Barnsley, and 170 more…'
|
||||
|
||||
wards = broadcast_area_libraries.get(
|
||||
'electoral-wards-of-the-united-kingdom',
|
||||
'wd20-lad20',
|
||||
).get_examples()
|
||||
assert wards == 'Aberdeen City, Aberdeenshire, Adur, and 375 more…'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('id', (
|
||||
'countries-E92000001',
|
||||
'countries-N92000002',
|
||||
'countries-S92000003',
|
||||
'countries-W92000004',
|
||||
'ctry19-E92000001',
|
||||
'ctry19-N92000002',
|
||||
'ctry19-S92000003',
|
||||
'ctry19-W92000004',
|
||||
pytest.param('mercia', marks=pytest.mark.xfail(raises=KeyError)),
|
||||
))
|
||||
def test_loads_areas_from_libraries(id):
|
||||
assert (
|
||||
broadcast_area_libraries.get('countries').get(id)
|
||||
broadcast_area_libraries.get('ctry19').get(id)
|
||||
) == (
|
||||
broadcast_area_libraries.get_areas(id)[0]
|
||||
)
|
||||
@@ -73,10 +73,10 @@ def test_loads_areas_from_libraries(id):
|
||||
|
||||
def test_get_names_of_areas():
|
||||
areas = broadcast_area_libraries.get_areas(
|
||||
'countries-W92000004',
|
||||
'electoral-wards-of-the-united-kingdom-W06000014',
|
||||
'countries-E92000001',
|
||||
'counties-and-unitary-authorities-in-england-and-wales-E10000012',
|
||||
'ctry19-W92000004',
|
||||
'lad20-W06000014',
|
||||
'ctry19-E92000001',
|
||||
'ctyua16-E10000012',
|
||||
|
||||
)
|
||||
assert [area.name for area in sorted(areas)] == [
|
||||
@@ -87,52 +87,53 @@ def test_get_names_of_areas():
|
||||
def test_get_areas_accepts_lists():
|
||||
areas_from_list = broadcast_area_libraries.get_areas(
|
||||
[
|
||||
'countries-W92000004',
|
||||
'counties-and-unitary-authorities-in-england-and-wales-W06000014',
|
||||
'countries-E92000001',
|
||||
'counties-and-unitary-authorities-in-england-and-wales-E10000012',
|
||||
'ctry19-W92000004',
|
||||
'ctyua16-W06000014',
|
||||
'ctry19-E92000001',
|
||||
'ctyua16-E10000012',
|
||||
]
|
||||
)
|
||||
areas_from_args = broadcast_area_libraries.get_areas(
|
||||
'countries-W92000004',
|
||||
'counties-and-unitary-authorities-in-england-and-wales-W06000014',
|
||||
'countries-E92000001',
|
||||
'counties-and-unitary-authorities-in-england-and-wales-E10000012',
|
||||
'ctry19-W92000004',
|
||||
'ctyua16-W06000014',
|
||||
'ctry19-E92000001',
|
||||
'ctyua16-E10000012',
|
||||
)
|
||||
assert len(areas_from_args) == len(areas_from_list) == 4
|
||||
assert areas_from_args == areas_from_list
|
||||
|
||||
|
||||
def test_has_polygons():
|
||||
|
||||
assert len(
|
||||
broadcast_area_libraries.get_polygons_for_areas_long_lat('countries-E92000001')
|
||||
broadcast_area_libraries.get_polygons_for_areas_long_lat('ctry19-E92000001')
|
||||
) == 35
|
||||
|
||||
assert len(
|
||||
broadcast_area_libraries.get_polygons_for_areas_long_lat('countries-S92000003')
|
||||
broadcast_area_libraries.get_polygons_for_areas_long_lat('ctry19-S92000003')
|
||||
) == 195
|
||||
|
||||
assert len(
|
||||
broadcast_area_libraries.get_polygons_for_areas_long_lat(
|
||||
'countries-E92000001',
|
||||
'countries-S92000003',
|
||||
'ctry19-E92000001',
|
||||
'ctry19-S92000003',
|
||||
)
|
||||
) == 35 + 195 == 230
|
||||
|
||||
assert len(
|
||||
broadcast_area_libraries.get_polygons_for_areas_lat_long(
|
||||
'countries-E92000001',
|
||||
'countries-S92000003',
|
||||
'ctry19-E92000001',
|
||||
'ctry19-S92000003',
|
||||
)
|
||||
) == 35 + 195 == 230
|
||||
|
||||
assert broadcast_area_libraries.get_polygons_for_areas_lat_long('countries-E92000001')[0][0] == [
|
||||
assert broadcast_area_libraries.get_polygons_for_areas_lat_long('ctry19-E92000001')[0][0] == [
|
||||
55.811085, -2.034358 # https://goo.gl/maps/wsf2LUWzYinwydMk8
|
||||
]
|
||||
|
||||
|
||||
def test_polygons_are_enclosed_unless_asked_not_to_be():
|
||||
england = broadcast_area_libraries.get('countries').get('countries-E92000001')
|
||||
england = broadcast_area_libraries.get('ctry19').get('ctry19-E92000001')
|
||||
|
||||
assert len(england.polygons) == len(england.unenclosed_polygons)
|
||||
|
||||
@@ -148,8 +149,8 @@ def test_polygons_are_enclosed_unless_asked_not_to_be():
|
||||
|
||||
def test_lat_long_order():
|
||||
|
||||
lat_long = broadcast_area_libraries.get_polygons_for_areas_lat_long('countries-E92000001')
|
||||
long_lat = broadcast_area_libraries.get_polygons_for_areas_long_lat('countries-E92000001')
|
||||
lat_long = broadcast_area_libraries.get_polygons_for_areas_lat_long('ctry19-E92000001')
|
||||
long_lat = broadcast_area_libraries.get_polygons_for_areas_long_lat('ctry19-E92000001')
|
||||
assert len(lat_long[0]) == len(long_lat[0]) == 2082 # Coordinates in polygon
|
||||
assert len(lat_long[0][0]) == len(long_lat[0][0]) == 2 # Axes in coordinates
|
||||
assert lat_long[0][0] == list(reversed(long_lat[0][0]))
|
||||
@@ -157,19 +158,19 @@ def test_lat_long_order():
|
||||
|
||||
def test_includes_electoral_wards():
|
||||
|
||||
areas = broadcast_area_libraries.get_areas(['electoral-wards-of-the-united-kingdom-E05009289'])
|
||||
areas = broadcast_area_libraries.get_areas(['wd20-E05009289'])
|
||||
assert len(areas) == 1
|
||||
|
||||
|
||||
def test_electoral_wards_are_groupable_cardiff():
|
||||
areas = broadcast_area_libraries.get_areas(['electoral-wards-of-the-united-kingdom-W06000015'])
|
||||
areas = broadcast_area_libraries.get_areas(['lad20-W06000015'])
|
||||
assert len(areas) == 1
|
||||
cardiff = areas[0]
|
||||
assert len(cardiff.sub_areas) == 29
|
||||
|
||||
|
||||
def test_electoral_wards_are_groupable_ealing():
|
||||
areas = broadcast_area_libraries.get_areas(['electoral-wards-of-the-united-kingdom-E09000009'])
|
||||
areas = broadcast_area_libraries.get_areas(['lad20-E09000009'])
|
||||
assert len(areas) == 1
|
||||
ealing = areas[0]
|
||||
assert len(ealing.sub_areas) == 23
|
||||
@@ -183,5 +184,5 @@ def test_repository_has_all_libraries():
|
||||
assert [
|
||||
'Counties and Unitary Authorities in England and Wales',
|
||||
'Countries',
|
||||
'Electoral Wards of the United Kingdom',
|
||||
'Local authorities',
|
||||
] == sorted([name for _, name, _is_group in libraries])
|
||||
|
||||
Reference in New Issue
Block a user