Say what each season is: the note on an estimate ends that this is the usual window, not a closure; month lists and the figures notes tell estimated from the climate and similar trails from set by judgement from pages that differ; the changelog no longer says the glossary gives the test figures

This commit is contained in:
swaits committed 2026-11-20 14:38:44 -07:00
1 parent c3d43f41a7
commit e6c2f371fc
12 files changed
+91 -25

No files matched your search

+24 -3
View File
@@ -189,10 +189,30 @@ class SeasonTextTest(unittest.TestCase):
note = facets.season_note(rec)
for want in ("No page states a season", "estimated from the climate at the trail's elevation and from "
"similar trails", "Snow keeps the high passes closed until June.", "Confidence: medium.",
"People do walk it outside these months."):
"This is the usual window, not a closure."):
self.assertIn(want, note)
self.assertNotIn("walk it outside", note)
self.assertNotIn("Judged from", note) # the standard lead is said once, in the note's own words
def test_a_page_that_contradicts_itself_is_said_once_not_twice(self):
rec = fake(1, hike=est_hike(season_method=(
"A page was found but it contradicts itself, so no page is relied on. The season was estimated "
"from the climate and similar trails: snow lies until June. Confidence: medium.")))
note = facets.season_note(rec)
self.assertTrue(note.startswith("No page states a season. A page was found but it contradicts itself"), note)
self.assertEqual(note.count("estimated from the climate"), 1)
self.assertTrue(note.endswith("This is the usual window, not a closure."))
def test_a_season_judged_from_pages_is_not_called_estimated_from_climate(self):
judged = fake(1, hike=est_hike(season_basis="sources", season_method="The pages differ. Confidence: low."))
est = fake(2, hike=est_hike())
self.assertEqual(facets.season_unstated_clause([est, est, judged]),
"2 are estimated from the climate and similar trails and 1 is set by judgement from "
"pages that differ")
self.assertEqual(facets.season_unstated_clause([judged]), "1 is set by judgement from pages that differ")
self.assertEqual(facets.season_unstated_clause([est]), "1 is estimated from the climate and similar trails")
self.assertEqual(facets.season_unstated_clause([]), "")
def test_a_stated_season_is_unchanged_and_has_no_note(self):
rec = fake(1, hike={"season": "June to September", "months": [6, 7, 8, 9], "season_basis": "primary"})
self.assertFalse(facets.season_estimated(rec))
@@ -365,9 +385,10 @@ class BuiltVocabularyTest(unittest.TestCase):
for rec in est[:10]:
doc = self.read(f"trails/{rec['id']}/index.html")
self.assertIn(facets.season_text(rec), html.unescape(doc), rec["id"])
self.assertIn("People do walk it outside these months.", html.unescape(doc), rec["id"])
self.assertIn("This is the usual window, not a closure.", html.unescape(doc), rec["id"])
self.assertNotIn("outside these months", html.unescape(doc), rec["id"])
for rec in stated[:10]:
self.assertNotIn("People do walk it outside these months.", html.unescape(self.read(f"trails/{rec['id']}/index.html")))
self.assertNotIn("This is the usual window", html.unescape(self.read(f"trails/{rec['id']}/index.html")))
def test_navigation_has_four_sections_and_saved(self):
doc = self.read("index.html")
+2 -1
View File
@@ -147,7 +147,8 @@ class TrailPageTest(unittest.TestCase):
self.assertIn("Season About April to October", t)
self.assertIn("No page states a season.", t)
self.assertIn("Confidence: high.", t)
self.assertIn("People do walk it outside these months.", t)
self.assertIn("This is the usual window, not a closure.", t)
self.assertNotIn("People do walk", t)
self.assertIn("No source gives a season; the climate suggests about April to October.", t)
self.assertNotIn("The usual season is", t)
block = html.unescape(trail.hike_sources_block(rec))
+16 -3
View File
@@ -138,7 +138,20 @@ class MonthListTest(unittest.TestCase):
+ [self.est(20 + i) for i in range(5)]
note = july.note(browse.members(july, recs), recs)
self.assertEqual(note, "A source states the season for 10 of these. For the other 5 it is estimated "
"from climate, and marked.")
"from the climate and similar trails, and marked.")
def test_a_month_note_tells_estimated_from_judged_from_pages_that_differ(self):
july = browse.by_key("hike-in-july")
judged = fake(90, hike={"months": [7], "season": "July", "season_basis": "sources",
"season_method": "The pages differ. Confidence: low."})
stated = fake(91, hike={"months": [7], "season": "July", "season_basis": "primary"})
recs = [stated, judged] + [self.est(20 + i) for i in range(3)]
self.assertEqual(july.note(browse.members(july, recs), recs),
"A source states the season for 1 of these. For the other 4, 3 are estimated from the climate "
"and similar trails and 1 is set by judgement from pages that differ, and marked.")
recs = [judged, judged]
self.assertEqual(july.note(browse.members(july, recs), recs),
"No source states the season for these, so each is set by judgement from pages that differ.")
def test_a_month_list_with_no_estimates_says_so(self):
july = browse.by_key("hike-in-july")
@@ -146,7 +159,7 @@ class MonthListTest(unittest.TestCase):
self.assertEqual(july.note(browse.members(july, recs), recs), "A source states the season for all 10.")
recs = [self.est(i) for i in range(3)]
self.assertEqual(july.note(browse.members(july, recs), recs),
"No source states the season for these, so each is estimated from climate.")
"No source states the season for these, so each is estimated from the climate and similar trails.")
def test_the_month_blurb_no_longer_says_only_some_trails(self):
group = {key: blurb for key, _title, blurb in browse.GROUPS}["month"]
@@ -681,7 +694,7 @@ class RealDataTest(unittest.TestCase):
kinds = {k: sum(1 for r in self.records if facets.season_kind(r) == k) for k in ("stated", "judged", "estimated")}
self.assertEqual(sum(kinds.values()), len(self.records))
self.assertIn(f"A season a page states Records with it {kinds['stated']} Records without {len(self.records) - kinds['stated']}", text)
self.assertIn(f"A season estimated from climate Records with it {kinds['estimated']} Records without {len(self.records) - kinds['estimated']}", text)
self.assertIn(f"A season estimated from the climate and similar trails Records with it {kinds['estimated']} Records without {len(self.records) - kinds['estimated']}", text)
self.assertIn(f"A season set from pages that differ Records with it {kinds['judged']} Records without {len(self.records) - kinds['judged']}", text)
self.assertIn(f"All trails Trails {len(self.records)}", text)