Allow a season method with sources, where the pages differ

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 10:38:35 -07:00
1 parent cb6cdadd41
commit 667b2ea00f
4 files changed
+27 -6

No files matched your search

+9 -5
View File
@@ -41,14 +41,18 @@ def check_season(tid, hike, errors):
errors.append(
f"{tid}: hike.season_basis must be one of {', '.join(BASES)}, not {basis!r}")
if basis == "estimate":
if has_method:
method = hike.get("season_method")
if not isinstance(method, str) or not method.strip():
errors.append(f"{tid}: hike.season_method is required with season_basis \"estimate\"")
if basis not in ("estimate", "sources"):
errors.append(
f"{tid}: hike.season_method is only given with season_basis \"estimate\" "
"or \"sources\"")
elif not isinstance(method, str) or not method.strip():
errors.append(f"{tid}: hike.season_method must not be empty")
elif len(method) >= 400:
errors.append(f"{tid}: hike.season_method must be under 400 characters")
elif has_method:
errors.append(f"{tid}: hike.season_method is only given with season_basis \"estimate\"")
elif basis == "estimate":
errors.append(f"{tid}: hike.season_method is required with season_basis \"estimate\"")
naming_season = _naming(sources, "season")
if basis in ("primary", "source"):
+14
View File
@@ -80,6 +80,20 @@ class SeasonBasisTest(unittest.TestCase):
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)