Join the season photo picks: every season from 1950 to 2026 matched to its curated car
seasons/photos.json held only its note, so every season poster was drawn without a photo. It now
holds the 77 picks made by the curated car of each season (three runs: 1950-1975, 1976-2000,
2001-2026), keyed in year order. Licence, author and date of each were read from Commons' own
metadata. Where that date cannot be when the photo was taken, the entry says where its date
comes from: 1978, 1984, 1988 and 1991 from the description (Commons gives a scan or upload
date); 1989 the upload's month, 2012-08 (Commons' 2013-08-21 is the camera's clock, after the
upload of 2012-08-28, and neither the description, whose 1989 is the car's year, nor a category
says when it was taken). 1967's author is the photographer as Commons names him on his other
files, "edvvc from London, UK", without the uploader Commons' Artist field appends. The $comment
says where a candidate comes from, the match order and date_from's three values.
seasons/picks.md is the table of picks the design names: one row per season, newest first, the
curated car named and described (never its photo, never where it is kept), the picked file, its
licence, the match and why, joined from the three runs' tables. 1957, 1975 and 1977 are not in
their season's cars category (searched as the candidates tool searches it, and their own
categories walked up): their rows say they were found by a search for the car by name. Five
seasons are not the same car: 1952 (the champion's car), 1967, 2023 and 2026 (the same team's
car of that season), 1971 (the same model in the livery it raced that season).
The tests read both files as the service does: every season 1950-2026 written in year order and
accepted by poster_sources' reader, each date_from one of the design's three; the table names
every picked season newest first, with the file and licence of seasons/photos.json and one of the
design's four matches (on master both fail: no season is picked, no table). The licence test
gains CC BY-SA 2.5 and the three ported licences the picks use (2.0 de, 3.0 de, 3.0 nl): free,
and the picture CC BY-SA 4.0; pick_share's docstring names them. The reader does not check
date_from, so it needs no change for "upload".
Builds: docs/posters.md at f6b9f937d0 (Season posters: each season's photo is matched to the curated car, the table of picks seasons/picks.md; Picking photos: the name search said in the pick's row, date and date_from, the ported CC BY-SA licences; Licences, stated: 2.5 and the ported licences)
Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
This commit is contained in:
@@ -80,6 +80,10 @@ class CreditAndLicenceTest(unittest.TestCase):
|
||||
self.assertEqual(ps.picture_licence(shares), licence, shares)
|
||||
with self.assertRaises(ps.LicenceClash):
|
||||
ps.picture_licence([by_sa, ps.eox(2025).share])
|
||||
# 2.5 and the ported licences allow a later version with the same elements, as 2.0 and 3.0 do
|
||||
for licence in ("CC BY-SA 2.5", "CC BY-SA 2.0 de", "CC BY-SA 3.0 de", "CC BY-SA 3.0 nl"):
|
||||
self.assertTrue(ps.is_free_licence(licence), licence)
|
||||
self.assertEqual(ps.picture_licence([ps.pick_share({"licence": licence})]), "CC BY-SA 4.0", licence)
|
||||
|
||||
def test_picks_skip_notes_and_refuse_what_they_cannot_use(self):
|
||||
with tempfile.TemporaryDirectory() as kept:
|
||||
@@ -102,6 +106,28 @@ class CreditAndLicenceTest(unittest.TestCase):
|
||||
self.assertEqual(len(logged.output), 4)
|
||||
for name in ("circuits/photos.json", "seasons/photos.json"):
|
||||
self.assertEqual(ps.read_picks(ROOT / name).get("$comment"), None, name)
|
||||
# Every season from 1950 to 2026 has its picked photo, keyed in year order, and the reader accepts each one
|
||||
written = json.loads((ROOT / "seasons/photos.json").read_text(encoding="utf-8"))
|
||||
seasons = [str(year) for year in range(1950, 2027)]
|
||||
self.assertEqual([key for key in written if not key.startswith("$")], seasons)
|
||||
self.assertEqual(list(ps.read_picks(ROOT / "seasons/photos.json")), seasons)
|
||||
for year in seasons: # where the date was read when Commons' own date cannot be when the photo was taken
|
||||
self.assertIn(written[year].get("date_from", "description"), ("description", "category", "upload"), year)
|
||||
|
||||
def test_the_table_of_picks_names_the_match_per_season(self):
|
||||
"""seasons/picks.md: one row per picked season, newest first, its file and licence those of
|
||||
seasons/photos.json, its match one of the design's four (docs/posters.md, Season posters)."""
|
||||
matches = ("same car", "same model, other livery", "same team and season", "champion")
|
||||
picks = ps.read_picks(ROOT / "seasons/photos.json")
|
||||
rows = []
|
||||
for line in (ROOT / "seasons/picks.md").read_text(encoding="utf-8").splitlines():
|
||||
if line.startswith("| ") and line[2:6].isdigit():
|
||||
rows.append([cell.strip() for cell in line.strip().strip("|").split(" | ")])
|
||||
self.assertEqual([row[0] for row in rows], sorted(picks, key=int, reverse=True))
|
||||
for year, curated, file, licence, match, why in rows:
|
||||
self.assertEqual((file, licence), (picks[year]["file"], picks[year]["licence"]), year)
|
||||
self.assertIn(match, matches, year)
|
||||
self.assertTrue(curated and why, year)
|
||||
|
||||
def test_the_picks_routes_answer_the_picks_as_the_service_has_them_loaded(self):
|
||||
photo = {"file": "A.jpg", "licence": "CC BY 4.0", "author": "A", "credit": "Photo: A", "date": "2020"}
|
||||
|
||||
Reference in New Issue
Block a user