38e20f2c30
Correctness: review vetoes persist via a dedupe_veto column (resolve re-runs no longer overturn humans); diff emits second copies whose confident version matches no owned copy (spec: pairs own only on both ids) and fetches the live collection with refresh; resolve pairs titles.json entries to rows by title so a reshoot photo updates provenance instead of duplicating rows; version lookups survive empty /thing results; publisher tie-break now honors the mixed base/expansion veto and refuses multi-candidate picks; empty-normalized (non-Latin) titles never count as exact. Upload: LoginError aborts a run instead of logging N bogus failures (and 3 identical consecutive failures abort as systemic); Cloudflare interstitials are detected; added-without-version gets its own logged status that verify understands; same-game updates run one per pass so the name-targeted row edit can't overwrite a fresh version; absent diff outputs fail loudly; pagination clicks are paced. Web review: a lock serializes freshen/decide (threadpool race dropped decisions); failed saves roll memory back and always alert the browser (non-JSON 500s included); session warnings reach the page instead of a StringIO; state-load failures and dead servers show banners instead of a blank page; duplicate (title, photos) rows are addressable by ordinal. Consistency: shared CONFIDENT_VERSION_STATUSES, client_for(), Config paths for every artifact, one review-port constant, named matching thresholds, strict collection-id parsing, error-doc responses never cached, unknown config keys warn, extract reports dropped vision entries, fixture generators share escaping + marker text. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Config loading: toml knobs, env-only username, unknown-key warning."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from bggpipe.config import Config, load_config
|
|
|
|
|
|
def test_defaults_when_no_file(tmp_path, monkeypatch):
|
|
monkeypatch.delenv("BGG_USERNAME", raising=False)
|
|
cfg = load_config(tmp_path / "missing.toml")
|
|
assert cfg == Config()
|
|
assert cfg.cache_dir == Path("data/bgg_cache")
|
|
|
|
|
|
def test_reads_toml(tmp_path, monkeypatch):
|
|
monkeypatch.delenv("BGG_USERNAME", raising=False)
|
|
p = tmp_path / "config.toml"
|
|
p.write_text('data_dir = "elsewhere"\nrate_limit_seconds = 3\n')
|
|
cfg = load_config(p)
|
|
assert cfg.data_dir == Path("elsewhere")
|
|
assert cfg.rate_limit_seconds == 3.0
|
|
assert cfg.matches_path == Path("elsewhere/matches.csv")
|
|
|
|
|
|
def test_username_comes_from_env_only(tmp_path, monkeypatch):
|
|
# the account has exactly one home: BGG_USERNAME in the environment —
|
|
# a bgg_username key in config.toml is deliberately ignored
|
|
p = tmp_path / "config.toml"
|
|
p.write_text('bgg_username = "from_toml"\n')
|
|
monkeypatch.setenv("BGG_USERNAME", "from_env")
|
|
assert load_config(p).bgg_username == "from_env"
|
|
monkeypatch.delenv("BGG_USERNAME")
|
|
assert load_config(p).bgg_username == ""
|
|
|
|
|
|
def test_unknown_toml_keys_warn(tmp_path, monkeypatch):
|
|
# a typo'd knob must not silently fall back to defaults
|
|
import pytest
|
|
|
|
monkeypatch.delenv("BGG_USERNAME", raising=False)
|
|
p = tmp_path / "config.toml"
|
|
p.write_text('photo_dir = "oops"\n')
|
|
with pytest.warns(UserWarning, match="photo_dir"):
|
|
load_config(p)
|