Merge branch 'main' into seasons-ship-3
This commit is contained in:
commit
072d568977
53 files changed
+811
-19
No files matched your search
@@ -476,6 +476,57 @@ asked_by = "the dataset's own check"
|
||||
'''
|
||||
|
||||
|
||||
SEASON_PROPOSAL = '''
|
||||
[[proposal]]
|
||||
kind = "change"
|
||||
id = "aaa"
|
||||
date = "2026-11-30"
|
||||
summary = "A season from the club's page."
|
||||
|
||||
[[proposal.edit]]
|
||||
field = "hike.season"
|
||||
new = "Late June to mid-September"
|
||||
page = "https://example.org/aaa/season"
|
||||
quote = "Hike it from late June through mid-September."
|
||||
|
||||
[[proposal.edit]]
|
||||
field = "hike.months"
|
||||
new = [7, 8, 9]
|
||||
page = "https://example.org/aaa/season"
|
||||
quote = "Hike it from late June through mid-September."
|
||||
|
||||
[[proposal.edit]]
|
||||
field = "hike.season_basis"
|
||||
new = "primary"
|
||||
page = "https://example.org/aaa/season"
|
||||
quote = "Hike it from late June through mid-September."
|
||||
|
||||
[[proposal.edit]]
|
||||
field = "hike.checked"
|
||||
old = "2026-11-13"
|
||||
new = "2026-11-30"
|
||||
page = "https://example.org/aaa/season"
|
||||
quote = "Hike it from late June through mid-September."
|
||||
|
||||
[[proposal.append]]
|
||||
table = "hike.source"
|
||||
page = "https://example.org/aaa/season"
|
||||
quote = "Hike it from late June through mid-September."
|
||||
|
||||
[proposal.append.entry]
|
||||
url = "https://example.org/aaa/season"
|
||||
publisher = "Example Club"
|
||||
facts = ["season", "months"]
|
||||
|
||||
[proposal.history]
|
||||
change = "The record gained a season."
|
||||
basis = "The club's page says: Hike it from late June through mid-September."
|
||||
basis_url = "https://example.org/aaa/season"
|
||||
fields = ["hike.season", "hike.months", "hike.season_basis"]
|
||||
asked_by = "the dataset's own check"
|
||||
'''
|
||||
|
||||
|
||||
class CollectTest(Tmp):
|
||||
def collect(self):
|
||||
code, out = main(self.root, "--dir", self.d, "collect")
|
||||
@@ -731,6 +782,22 @@ class ApplyTest(Tmp):
|
||||
H.check_entries("aaa", rec, errors)
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
def test_a_researched_season_proposal_collects_and_applies(self):
|
||||
import validate as V
|
||||
propose(self.d, "season-01", "aaa", SEASON_PROPOSAL)
|
||||
self.collect_accept_all()
|
||||
code, out = self.apply()
|
||||
self.assertEqual(code, 0, out)
|
||||
rec = self.rec("aaa")
|
||||
self.assertEqual(rec["hike"]["season"], "Late June to mid-September")
|
||||
self.assertEqual(rec["hike"]["months"], [7, 8, 9])
|
||||
self.assertEqual(rec["hike"]["season_basis"], "primary")
|
||||
self.assertEqual(rec["hike"]["source"][-1]["facts"], ["season", "months"])
|
||||
errors = []
|
||||
V.season.check_season("aaa", rec["hike"], errors)
|
||||
H.check_entries("aaa", rec, errors)
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
def test_only_accepted_proposals_apply(self):
|
||||
propose(self.d, "trails-01", "aaa", PERMIT_CHANGE)
|
||||
main(self.root, "--dir", self.d, "collect")
|
||||
|
||||
@@ -73,6 +73,27 @@ class SeasonBasisTest(unittest.TestCase):
|
||||
errors = check(season_basis="source", source=[src("Guide A", facts=("days",))])
|
||||
self.assertTrue(errors)
|
||||
|
||||
def test_source_basis_needs_exactly_one_publisher(self):
|
||||
two = [src("Park Service"), src("Blog", url="https://example.org/b")]
|
||||
errors = check(season_basis="source", source=two)
|
||||
self.assertTrue(any("exactly one publisher" in e for e in errors), errors)
|
||||
same = [src("Park Service"), src("Park Service", url="https://example.org/b")]
|
||||
self.assertEqual(check(season_basis="source", source=same), [])
|
||||
|
||||
def test_method_is_allowed_with_sources_only_besides_estimate(self):
|
||||
two = [src("Park Service"), src("Blog", url="https://example.org/b")]
|
||||
ok = check(season_basis="sources", source=two,
|
||||
season_method="The pages differ; set from both and the climate estimate.")
|
||||
self.assertEqual(ok, [])
|
||||
self.assertEqual(check(season_basis="sources", source=two), [])
|
||||
for basis in ("primary", "source"):
|
||||
errors = check(season_basis=basis, season_method="Some sentence.")
|
||||
self.assertTrue(any("season_method" in e for e in errors), (basis, errors))
|
||||
long = check(season_basis="sources", source=two, season_method="x" * 401)
|
||||
self.assertTrue(any("400" in e for e in long), long)
|
||||
blank = check(season_basis="sources", source=two, season_method=" ")
|
||||
self.assertTrue(any("season_method" in e for e in blank), blank)
|
||||
|
||||
def test_primary_needs_a_naming_source(self):
|
||||
errors = check(source=[src("Park Service", facts=("days",))])
|
||||
self.assertTrue(errors)
|
||||
|
||||
@@ -95,7 +95,7 @@ class TableTest(unittest.TestCase):
|
||||
r = refresh.load_toml(os.path.join(V.ROOT, tid, "trail.toml"))
|
||||
if (r.get("hike") or {}).get("season"):
|
||||
expected += 1
|
||||
self.assertEqual(expected, 109)
|
||||
self.assertGreaterEqual(expected, 109)
|
||||
self.assertEqual(len(rows), expected)
|
||||
for row in rows:
|
||||
self.assertIn(row["suggested"], season.BASES)
|
||||
|
||||
Reference in new issue
Block a user