broadcast-areas: examples are deterministic

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
This commit is contained in:
Toby Lorne
2020-08-11 11:33:27 +01:00
parent 73e68c355b
commit b0ff2d41c5
3 changed files with 23 additions and 28 deletions

View File

@@ -1,5 +1,3 @@
import re
import pytest
from app.broadcast_areas import (
@@ -49,14 +47,21 @@ def test_loads_areas_from_library():
def test_examples():
assert re.match(
"^([^,]*, ){3}[^,]*",
broadcast_area_libraries.get('countries').get_examples(),
)
assert re.match(
"^([^,]*, ){4}and 5 more…$",
broadcast_area_libraries.get('regions-of-england').get_examples()
)
countries = broadcast_area_libraries.get('countries').get_examples()
assert countries == 'England, Northern Ireland, Scotland, Wales'
regions = broadcast_area_libraries.get('regions-of-england').get_examples()
assert regions == 'North East, North West, Yorkshire and The Humber, East Midlands, and 5 more…'
counties = broadcast_area_libraries.get(
'counties-and-unitary-authorities-in-england-and-wales',
).get_examples()
assert counties == 'Hartlepool, Middlesbrough, Redcar and Cleveland, Stockton-on-Tees, and 170 more…'
wards = broadcast_area_libraries.get(
'electoral-wards-of-the-united-kingdom',
).get_examples()
assert wards == 'Abbey, Alibon, Becontree, Chadwell Heath, and 8970 more…'
@pytest.mark.parametrize('id', (

View File

@@ -232,19 +232,15 @@ def test_choose_broadcast_library_page(
for title in page.select('.file-list-filename-large')
]
assert sorted(titles) == sorted([
'Counties and Unitary Authorities in England and Wales',
'Countries',
'Electoral Wards of the United Kingdom',
'Regions of England',
'Counties and Unitary Authorities in England and Wales',
'Countries',
'Electoral Wards of the United Kingdom',
'Regions of England',
])
assert any([
all([
country in hint.text
for country in ('England', 'Northern Ireland', 'Scotland', 'Wales')
])
for hint in page.select('.file-list-hint-large')
])
assert normalize_spaces(page.select('.file-list-hint-large')[1].text) == (
'England, Northern Ireland, Scotland, Wales'
)
assert page.select_one('a.file-list-filename-large.govuk-link')['href'] == url_for(
'.choose_broadcast_area',