mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-03-01 23:01:00 -05:00
Merge pull request #3563 from alphagov/better-library-examples
Improve examples given for broadcast area libraries
This commit is contained in:
@@ -114,11 +114,14 @@ class BroadcastAreasRepository(object):
|
||||
def get_library_description(self, library_id):
|
||||
q = """
|
||||
WITH
|
||||
areas AS (SELECT * FROM broadcast_areas
|
||||
WHERE broadcast_area_library_id = ?),
|
||||
areas AS (
|
||||
SELECT * FROM broadcast_areas
|
||||
WHERE broadcast_area_library_id = ?
|
||||
AND broadcast_area_library_group_id IS NULL
|
||||
),
|
||||
area_count AS (SELECT COUNT(*) AS c FROM areas),
|
||||
subset_area_count AS (SELECT c - 4 FROM area_count),
|
||||
description_area_names AS (SELECT name FROM areas LIMIT 4),
|
||||
description_area_names AS (SELECT name FROM areas ORDER BY name ASC LIMIT 3),
|
||||
description_areas_joined AS (
|
||||
SELECT GROUP_CONCAT(name, ", ") FROM description_area_names
|
||||
)
|
||||
@@ -126,6 +129,8 @@ class BroadcastAreasRepository(object):
|
||||
CASE (SELECT * FROM subset_area_count)
|
||||
WHEN 0 THEN
|
||||
(SELECT * FROM description_areas_joined)
|
||||
|| ", and "
|
||||
|| (SELECT name from areas ORDER BY name DESC limit 1)
|
||||
ELSE
|
||||
(SELECT * FROM description_areas_joined)
|
||||
|| ", and "
|
||||
|
||||
@@ -48,20 +48,20 @@ def test_loads_areas_from_library():
|
||||
|
||||
def test_examples():
|
||||
countries = broadcast_area_libraries.get('countries').get_examples()
|
||||
assert countries == 'England, Northern Ireland, Scotland, Wales'
|
||||
assert countries == 'England, Northern Ireland, Scotland, and 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…'
|
||||
assert regions == 'East Midlands, East of England, London, 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…'
|
||||
assert counties == 'Barking and Dagenham, Barnet, Barnsley, 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…'
|
||||
assert wards == 'Aberdeen City, Aberdeenshire, Adur, and 375 more…'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('id', (
|
||||
|
||||
@@ -299,7 +299,7 @@ def test_choose_broadcast_library_page(
|
||||
])
|
||||
|
||||
assert normalize_spaces(page.select('.file-list-hint-large')[1].text) == (
|
||||
'England, Northern Ireland, Scotland, Wales'
|
||||
'England, Northern Ireland, Scotland, and Wales'
|
||||
)
|
||||
|
||||
assert page.select_one('a.file-list-filename-large.govuk-link')['href'] == url_for(
|
||||
|
||||
Reference in New Issue
Block a user