Reword the lists in the words people search with: the longest names its longest trail first, short thru-hikes and loops under 100 and 200 miles, week-long and other backpacking trips, backpacking loops; the week list gains pages for states and places
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b75d39c7b6
commit
4c72fd705e
7 files changed
+118
-28
No files matched your search
@@ -6,7 +6,7 @@
|
||||
"/regions/mountain-west/": "6151f5a28d366fb48aab7027f08cea6da425201d0e7327780a01dd77cedc7bc7",
|
||||
"/regions/north/": "85ba3ea850c2df690e311cf09257f2548ed888c07c319a01fd30d5e19cdf1fd4",
|
||||
"/regions/us-co/": "97daaf3511578896b222570cba630da2d8ca0571504ce43b3685dbe532e40f56",
|
||||
"/regions/us-co/loops/": "03896834b5369655f7b5f26634b6d23c834b17f1a25b0ec328d44934e20e2dfa",
|
||||
"/regions/us-co/loops/": "5a116735c701f1840ad00646a02682afc177c585fc06763f5b5a6b8afccff4a8",
|
||||
"/regions/us-co/with-gpx/": "d82eace3d70eb9b1ef1346f5a3470199bd6a00e6e104fe661bfeb80199af96b8",
|
||||
"/regions/us-hi/": "1e5681ffbd50e382db7d69528fde602069006bf0cddad494d817369224bd96ad",
|
||||
"/regions/us-ut/": "906db4153def35fa5418d0b86dba908fd27396bbc2098978ee169516e1b39785",
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
"""The wording of the ready-made lists (olt/browse.py): titles in the words people search with.
|
||||
Addresses and rules do not change; only title, blurb, page_title, noun and lede."""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, WEB)
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from olt import browse, common, records # noqa: E402
|
||||
from test_facets import BANNED # noqa: E402
|
||||
|
||||
KEYS = ['national-scenic-trails', 'national-recreation-trails', 'routes', 'high-routes', 'longest', '500-to-1000-miles', '200-to-500-miles', '100-to-200-miles', 'under-100-miles', 'under-200-miles', 'weekend', 'a-week-or-less', 'one-to-two-weeks', 'two-to-four-weeks', 'a-month-or-more', 'loops', 'off-trail', 'mostly-cross-country', 'unfinished', 'parks-canada', 'forest-service', 'state-and-provincial-parks', 'clubs-and-associations', 'with-gpx', 'canada', 'united-states', 'terrain-alpine', 'terrain-forest', 'terrain-desert', 'terrain-coast', 'terrain-prairie', 'terrain-canyon', 'terrain-tundra', 'terrain-lakes', 'terrain-farmland', 'hike-in-january', 'hike-in-february', 'hike-in-march', 'hike-in-april', 'hike-in-may', 'hike-in-june', 'hike-in-july', 'hike-in-august', 'hike-in-september', 'hike-in-october', 'hike-in-november', 'hike-in-december']
|
||||
|
||||
|
||||
class ListWordingTest(unittest.TestCase):
|
||||
def test_list_urls_and_keys_are_unchanged(self):
|
||||
self.assertEqual([lst.key for lst in browse.LISTS], KEYS)
|
||||
self.assertEqual(browse.path(browse.by_key("loops")), "/lists/loops/")
|
||||
self.assertEqual(browse.path(browse.by_key("routes")), "/routes/")
|
||||
|
||||
def test_the_reworded_lists_have_the_new_page_titles(self):
|
||||
want = {
|
||||
"longest": "Longest Hiking Trails in the US: 7 Trails of 1,000+ Miles",
|
||||
"under-100-miles": "Short Thru-Hikes and Loops Under 100 Miles: 7 Trails",
|
||||
"under-200-miles": "Thru-Hikes and Loops Under 200 Miles: 7 Trails",
|
||||
"a-week-or-less": "Week-Long Backpacking Trips: 7 Long Trails",
|
||||
"loops": "Backpacking Loops: 7 Long Trail Loops",
|
||||
}
|
||||
for key, title in want.items():
|
||||
self.assertEqual(browse.by_key(key).search_title(7), title)
|
||||
|
||||
def test_a_loop_is_never_called_a_thru_hike_alone(self):
|
||||
# the length bands hold loops too, so their titles say so
|
||||
for key in ("under-100-miles", "under-200-miles"):
|
||||
self.assertIn("Loops", browse.by_key(key).page_title)
|
||||
self.assertNotIn("thru", browse.by_key("loops").page_title.lower())
|
||||
|
||||
def test_the_week_band_has_a_noun_and_loops_say_backpacking(self):
|
||||
self.assertEqual(browse.by_key("a-week-or-less").noun, "Week-Long Backpacking Trips")
|
||||
self.assertEqual(browse.by_key("loops").noun, "Backpacking Loops")
|
||||
|
||||
def test_no_banned_word_and_no_best_in_any_list_wording(self):
|
||||
for lst in browse.LISTS:
|
||||
for text in (lst.title, lst.blurb, lst.search_title(9), lst.noun, lst.short):
|
||||
for pattern in BANNED:
|
||||
self.assertIsNone(re.search(pattern, text, re.I), (lst.key, text))
|
||||
self.assertIsNone(re.search(r"\bbest\b", text, re.I), (lst.key, text))
|
||||
|
||||
def test_every_search_title_is_unique_and_fits(self):
|
||||
titles = [lst.search_title(99) for lst in browse.LISTS]
|
||||
self.assertEqual(len(titles), len(set(titles)))
|
||||
for t in titles:
|
||||
self.assertLessEqual(len(t), common.TITLE_LIMIT, t)
|
||||
|
||||
def test_the_longest_list_names_the_longest_trail_and_its_length_first(self):
|
||||
recs = records.load_records(records.ROOT)
|
||||
lst = browse.by_key("longest")
|
||||
top = max(browse.members(lst, recs), key=lambda r: (r["length_km"], r["id"]))
|
||||
first = lst.lede(browse.members(lst, recs))
|
||||
self.assertTrue(first.startswith("The longest hiking trail"), first)
|
||||
self.assertIn(common.plain_name(top), first)
|
||||
self.assertIn(f"{top['derived']['length_mi']:,.0f} miles", first)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -188,13 +188,13 @@ class PlaceAndListTitleTest(unittest.TestCase):
|
||||
title = lst.search_title(999)
|
||||
self.assertLessEqual(len(title), ROOM, title)
|
||||
self.assertIn("999", title)
|
||||
self.assertEqual(browse.by_key("loops").search_title(32), "Loop Hiking Trails: 32 Long Trail Loops")
|
||||
self.assertEqual(browse.by_key("loops").search_title(32), "Backpacking Loops: 32 Long Trail Loops")
|
||||
|
||||
def test_list_description_adds_to_the_title(self):
|
||||
lst = browse.by_key("under-100-miles")
|
||||
members = browse.members(lst, [fake(i, km=100) for i in range(1, 5)])
|
||||
title, desc = regions.list_page(lst, members, 20, S)[:2]
|
||||
self.assertTrue(title.startswith("Hiking Trails Under 100 Miles: 4"))
|
||||
self.assertTrue(title.startswith("Short Thru-Hikes and Loops Under 100 Miles: 4"))
|
||||
self.assertLessEqual(len(desc), common.DESCRIPTION_LIMIT)
|
||||
self.assertTrue(desc.startswith(lst.blurb))
|
||||
self.assertIn("4 trails", desc)
|
||||
|
||||
@@ -55,7 +55,7 @@ class LengthBandTest(unittest.TestCase):
|
||||
def test_under_200_is_the_two_short_bands(self):
|
||||
recs = [fake(1, km=mi(50)), fake(2, km=mi(150)), fake(3, km=mi(250))]
|
||||
self.assertEqual(sorted(keys(recs, "under-200-miles")), ["t1", "t2"])
|
||||
self.assertTrue(browse.by_key("under-200-miles").search_title(9).startswith("Thru-Hikes Under 200 Miles"))
|
||||
self.assertTrue(browse.by_key("under-200-miles").search_title(9).startswith("Thru-Hikes and Loops Under 200 Miles"))
|
||||
|
||||
|
||||
class TimeListTest(unittest.TestCase):
|
||||
|
||||
Reference in new issue
Block a user