Username lives in .env only: drop bgg_username from config.toml

load_config no longer reads a bgg_username toml key — BGG_USERNAME in
the environment is its single home (public, but the account should have
exactly one). Docs, messages, and tests updated to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Eric Wagoner
2026-08-02 13:36:22 -04:00
parent 8e3cdc145f
commit abf7181475
6 changed files with 18 additions and 25 deletions
+7 -7
View File
@@ -13,19 +13,19 @@ def test_defaults_when_no_file(tmp_path, monkeypatch):
def test_reads_toml(tmp_path, monkeypatch):
monkeypatch.delenv("BGG_USERNAME", raising=False)
p = tmp_path / "config.toml"
p.write_text(
'bgg_username = "someone"\ndata_dir = "elsewhere"\nrate_limit_seconds = 3\n'
)
p.write_text('data_dir = "elsewhere"\nrate_limit_seconds = 3\n')
cfg = load_config(p)
assert cfg.bgg_username == "someone"
assert cfg.data_dir == Path("elsewhere")
assert cfg.rate_limit_seconds == 3.0
assert cfg.matches_path == Path("elsewhere/matches.csv")
def test_env_overrides_toml(tmp_path, monkeypatch):
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")
cfg = load_config(p)
assert cfg.bgg_username == "from_env"
assert load_config(p).bgg_username == "from_env"
monkeypatch.delenv("BGG_USERNAME")
assert load_config(p).bgg_username == ""
+2 -2
View File
@@ -1,7 +1,7 @@
"""The one test allowed to touch the real BGG API. Read-only, skipped by
default; run with: uv run pytest --run-live -m live
Needs bgg_username in config.toml and BGG_API_TOKEN in the environment
Needs BGG_USERNAME and BGG_API_TOKEN in the environment
(register at https://boardgamegeek.com/applications).
"""
@@ -20,7 +20,7 @@ from bggpipe.config import load_config
def test_fetch_own_collection_read_only(tmp_path: Path) -> None:
cfg = load_config()
if not cfg.bgg_username:
pytest.skip("set bgg_username in config.toml to run the live smoke test")
pytest.skip("set BGG_USERNAME to run the live smoke test")
if not os.environ.get("BGG_API_TOKEN"):
pytest.skip("set BGG_API_TOKEN to run the live smoke test")