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
44 lines
2.2 KiB
Python
44 lines
2.2 KiB
Python
"""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()
|