37 of its 39 links to files of the repository led nowhere: they named the upstream's flat circuits/<id>.geojson, not this repository's circuits/<country>/<locality>/<circuit>/<layout>.geo.json. It now says what the API serves, where the example site is, how the data is laid out, and lists every circuit with its Jolpica id and a link to each layout's GPS trace, written from circuits.json. A test holds every local link to a file. Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
21 lines
785 B
Python
21 lines
785 B
Python
"""Every link in README.md to a file of this repository leads to one."""
|
|
import re
|
|
import unittest
|
|
from pathlib import Path
|
|
from urllib.parse import unquote
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
class ReadmeLinksTest(unittest.TestCase):
|
|
def test_every_local_link_leads_to_a_file(self):
|
|
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
links = [link for link in re.findall(r"\]\(([^)\s]+)\)", readme) if not re.match(r"[a-z]+://", link)]
|
|
self.assertTrue(links, "README.md links no file")
|
|
broken = [link for link in links if not (ROOT / unquote(link.split("#")[0])).exists()]
|
|
self.assertEqual(broken, [], f"{len(broken)} of {len(links)} links in README.md lead to no file")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|