Fail the merge check on a point trace for a current race

Madring's point trace reached the 2026 poster unnoticed: nothing held that a layout a race draws
has a traced line. tests/test_traces.py takes every layout the service picks for a season from
2020 to next season (find_layout_slug_for_year over circuits.json, the data the posters draw
from) and fails each whose trace is not a LineString of more than ten points. On master it fails
on spain/madrid/madring/2026- alone; here it passes for all 35.

Builds: docs/posters.md at 8834df45e6 (Layers: no current race draws a layout without a traced line)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
This commit is contained in:
2026-11-30 10:20:48 +01:00
parent 613103e670
commit 82a0efabbc
2 changed files with 45 additions and 2 deletions
+2 -2
View File
@@ -10,8 +10,8 @@
# What the image ships, compiled before the merge: every Python file the service's image copies, and the
# models it imports. Then the tests in tests/, which need the standard library only: every circuit in
# circuits/circuits.json carries one unique ergastId, and a race's circuit resolves by that id, never by
# its name; a failed Jolpica fetch is never kept, a season that is over is read from disk, a throttled
# request is asked again; a poster's options, keys, cache headers and store cap, its satellite source, credits and
# its name; every layout a race from 2020 on draws has a traced line, never a point; a failed Jolpica
# fetch is never kept, a season that is over is read from disk, a throttled request is asked again; a poster's options, keys, cache headers and store cap, its satellite source, credits and
# licence (poster_options.py and poster_sources.py, standard library only).
#
# **Said, never passed silently**: the service's dependencies (service/requirements.txt) are the image's to
+43
View File
@@ -0,0 +1,43 @@
"""Every layout a race from 2020 on draws has a traced line: a layout whose trace is a point or empty is drawn without
a track (docs/posters.md, Layers), so such a trace for a current race fails the merge check.
The layouts are the ones the service picks for a season (CircuitService.find_layout_slug_for_year), read from
circuits.json, never from Jolpica's schedules. Standard library only, so the merge check runs it as it is.
"""
import json
import unittest
from datetime import date
from pathlib import Path
from circuits_service import CircuitService
ROOT = Path(__file__).resolve().parent.parent
FIRST_SEASON = 2020
MIN_POINTS = 10 # more than a few: a point, an empty line or a stub of a line fails
class TraceTest(unittest.TestCase):
def test_every_layout_raced_from_2020_on_has_a_traced_line(self):
service = CircuitService(str(ROOT / "circuits" / "circuits.json"))
drawn = set()
# This season and the next: a layout added for next season's calendar is held from the day it is added.
for season in range(FIRST_SEASON, date.today().year + 2):
for country in service.circuit_data.values():
for locality in country.localities.values():
for circuit in locality.circuits.values():
slug = service.find_layout_slug_for_year(circuit, season)
if slug is not None:
drawn.add(circuit.layouts[slug].relative_geojson_filepath)
self.assertIn(Path("spain/madrid/madring/2026-.geo.json"), drawn) # the newest layout is among them
for path in sorted(drawn):
with self.subTest(layout=str(path)):
geometry = json.loads((ROOT / "circuits" / path).read_text(encoding="utf-8"))["features"][0]["geometry"]
line = geometry["type"] == "LineString"
points = len(geometry["coordinates"]) if line else 0
found = f"a LineString of {points} points" if line else f"a {geometry['type']}"
self.assertGreater(points, MIN_POINTS, f"{path} is {found}, not a traced line of more than "
f"{MIN_POINTS} points")
if __name__ == "__main__":
unittest.main()