Add tests to ensure all areas have a count

This commit is contained in:
Chris Hill-Scott
2020-09-16 11:20:22 +01:00
parent 6b7908fecb
commit b9f75218d1
2 changed files with 34 additions and 5 deletions

View File

@@ -23,11 +23,11 @@ for min, max in SMARTPHONE_OWNERSHIP_BY_AGE_RANGE.keys():
class CITY_OF_LONDON:
WARDS = (
'E05009289', 'E05009290', 'E05009291', 'E05009292', 'E05009293',
'E05009294', 'E05009295', 'E05009296', 'E05009297', 'E05009298',
'E05009299', 'E05009300', 'E05009301', 'E05009302', 'E05009303',
'E05009304', 'E05009305', 'E05009306', 'E05009307', 'E05009308',
'E05009309', 'E05009310', 'E05009311', 'E05009312',
'E05009288', 'E05009289', 'E05009290', 'E05009291', 'E05009292',
'E05009293', 'E05009294', 'E05009295', 'E05009296', 'E05009297',
'E05009298', 'E05009299', 'E05009300', 'E05009301', 'E05009302',
'E05009303', 'E05009304', 'E05009305', 'E05009306', 'E05009307',
'E05009308', 'E05009309', 'E05009310', 'E05009311', 'E05009312',
)
# https://data.london.gov.uk/blog/daytime-population-of-london-2014/
DAYTIME_POPULATION = 553_000

View File

@@ -4,6 +4,7 @@ from app.broadcast_areas import (
BroadcastAreasRepository,
broadcast_area_libraries,
)
from app.broadcast_areas.constants import CITY_OF_LONDON
def test_loads_libraries():
@@ -147,3 +148,31 @@ def test_repository_has_all_libraries():
('Countries', 'country'),
('Local authorities', 'local authority'),
] == [(name, name_singular) for _, name, name_singular, _is_group in libraries]
@pytest.mark.parametrize('library', (
broadcast_area_libraries
))
def test_every_area_has_count_of_phones(library):
for area in library:
assert area.count_of_phones > 0
def test_bryher_has_hard_coded_count():
bryher = broadcast_area_libraries.get_areas('wd20-E05011090')[0]
assert bryher.name == 'Bryher'
assert bryher.count_of_phones == 76.44
def test_city_of_london_counts_are_not_derived_from():
city_of_london = broadcast_area_libraries.get_areas('lad20-E09000001')[0]
assert city_of_london.name == 'City of London'
assert len(city_of_london.sub_areas) == len(CITY_OF_LONDON.WARDS) == 25
for ward in city_of_london.sub_areas:
# The population of the whole City of London is 9,401, so an
# average of 300 per ward. What were asserting here is that the
# count of phones is much larger, because it isnt derived from
# the resident population.
assert ward.count_of_phones > 5_000