Resolve stage: matching, version resolution, fixtures; BGG API auth

bggpipe resolve works end to end: search -> exact/fuzzy candidate
scoring -> auto/ambiguous/unmatched classification with owned-count
tie-breaks (mixed base/expansion candidates never auto-match), version
scoring from edition cues (never guessed; no cues -> version_unknown),
idempotent matches.csv appends.

Discovered mid-build: BGG now requires registered-application Bearer
tokens on the XML API (2025 policy change) and returns 401 otherwise.
Client sends Authorization from BGG_API_TOKEN and raises an actionable
BGGAuthError; CLAUDE.md and the bgg-api skill are updated to match.
Live fixture recording is blocked until registration is approved, so
tests replay hand-crafted stub fixtures via a network-refusing
transport; scripts/record_fixtures.py re-records real XML under the
same cache keys once a token exists. One live read-only smoke test is
skipped unless --run-live.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Eric Wagoner
2026-08-01 12:33:32 -04:00
parent 4e1211feb6
commit 2109e3544a
20 changed files with 880 additions and 6 deletions
+23
View File
@@ -108,3 +108,26 @@ def test_cache_key_stable_and_filename_safe(tmp_path):
key2 = cache_key("search", {"type": "boardgame", "query": "Café & Krieg?"})
assert key1 == key2 # param order must not matter
assert "/" not in key1 and "?" not in key1 and key1.endswith(".xml")
def test_api_token_sent_as_bearer_header(tmp_path, monkeypatch):
monkeypatch.setenv("BGG_API_TOKEN", "test-token-123")
client, calls, _ = make_client(tmp_path, [(200, SEARCH_XML)])
client.get_xml("search", {"query": "catan"})
assert calls[0].headers["Authorization"] == "Bearer test-token-123"
def test_no_auth_header_without_token(tmp_path, monkeypatch):
monkeypatch.delenv("BGG_API_TOKEN", raising=False)
client, calls, _ = make_client(tmp_path, [(200, SEARCH_XML)])
client.get_xml("search", {"query": "catan"})
assert "authorization" not in calls[0].headers
def test_401_raises_actionable_auth_error(tmp_path, monkeypatch):
monkeypatch.delenv("BGG_API_TOKEN", raising=False)
from bggpipe.bgg_client import BGGAuthError
client, _, _ = make_client(tmp_path, [(401, "Unauthorized")])
with pytest.raises(BGGAuthError, match="BGG_API_TOKEN"):
client.get_xml("search", {"query": "catan"})