4f2ae5f525
First live vision run: 4 shelf photos -> 27 unique titles with edition cues (publishers, Bookcase Game/Designer's Edition wording, art notes); cross-photo dedupe merged repeat sightings. data/titles.json now holds real pipeline data, so the hand-typed resolve test list moves to tests/data/titles.json (tests and record_fixtures updated), and the matches.csv generated from stub fixtures for that list is removed — the real resolve run will regenerate it once the BGG token arrives. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Record the BGG XML fixtures the test suite replays.
|
|
|
|
Runs the real resolve logic with the cache pointed at tests/fixtures/
|
|
bgg_cache/, so exactly the responses resolve needs get recorded (live,
|
|
rate-limited). Run once; commit the fixtures. Re-running only fetches
|
|
whatever is not already recorded.
|
|
|
|
Usage: uv run python scripts/record_fixtures.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from bggpipe.bgg_client import BGGClient
|
|
from bggpipe.resolve import load_titles, resolve_entry
|
|
|
|
FIXTURE_CACHE = Path("tests/fixtures/bgg_cache")
|
|
|
|
|
|
def main() -> None:
|
|
if not os.environ.get("BGG_API_TOKEN"):
|
|
raise SystemExit(
|
|
"BGG_API_TOKEN is not set. The XML API requires a registered "
|
|
"application token (https://boardgamegeek.com/applications). "
|
|
"Until one exists, the committed fixtures are the hand-crafted "
|
|
"stubs from scripts/write_stub_fixtures.py; delete "
|
|
f"{FIXTURE_CACHE} and re-run this script to replace them with "
|
|
"real recordings."
|
|
)
|
|
client = BGGClient(cache_dir=FIXTURE_CACHE)
|
|
for entry in load_titles(Path("tests/data/titles.json")):
|
|
row = resolve_entry(client, entry)
|
|
print(
|
|
f"{entry.title_raw!r}: {row.match_status} "
|
|
f"{row.bgg_name or '-'} ({row.bgg_id or '-'}) {row.version_status}"
|
|
)
|
|
print(f"\nFixtures recorded in {FIXTURE_CACHE}:")
|
|
for f in sorted(FIXTURE_CACHE.iterdir()):
|
|
print(f" {f.name}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|