abf7181475
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>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
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 == ""
|