diff --git a/app/broadcast_areas/repo.py b/app/broadcast_areas/repo.py index d3de705c7..3ded4d264 100644 --- a/app/broadcast_areas/repo.py +++ b/app/broadcast_areas/repo.py @@ -105,13 +105,7 @@ class BroadcastAreasRepository(object): WHERE broadcast_area_library_id = ?), area_count AS (SELECT COUNT(*) AS c FROM areas), subset_area_count AS (SELECT c - 4 FROM area_count), - some_area_names AS (SELECT name FROM areas LIMIT 100), - some_shuffled_area_names AS ( - SELECT name FROM some_area_names ORDER BY RANDOM() - ), - description_area_names AS ( - SELECT name FROM some_shuffled_area_names LIMIT 4 - ), + description_area_names AS (SELECT name FROM areas LIMIT 4), description_areas_joined AS ( SELECT GROUP_CONCAT(name, ", ") FROM description_area_names ) diff --git a/tests/app/broadcast_areas/test_broadcast_area.py b/tests/app/broadcast_areas/test_broadcast_area.py index d0305c05e..4e8459de6 100644 --- a/tests/app/broadcast_areas/test_broadcast_area.py +++ b/tests/app/broadcast_areas/test_broadcast_area.py @@ -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', ( diff --git a/tests/app/main/views/test_broadcast.py b/tests/app/main/views/test_broadcast.py index cb4c64165..0570e1963 100644 --- a/tests/app/main/views/test_broadcast.py +++ b/tests/app/main/views/test_broadcast.py @@ -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',