mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 20:01:01 -05:00
broadcast-areas: examples are deterministic
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -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', (
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user