Files
bggpipe/tests/test_config.py
T
Eric Wagoner d58568cceb Scaffold bggpipe: typer CLI, config loading, title normalization
uv project with typer/httpx/rapidfuzz, ruff and pytest wired into
pyproject. Six stub subcommands matching the pipeline stages, config.toml
plus BGG_USERNAME env override, accent/ampersand/article-safe title
normalization with tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-01 12:23:00 -04:00

32 lines
1020 B
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(
'bgg_username = "someone"\ndata_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):
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"