first commit

This commit is contained in:
jsahn
2026-09-02 14:57:29 +09:00
commit c0b140d27f
60 changed files with 7520 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
"""Settings loading: CSV splitting, validation, derived properties."""
from __future__ import annotations
from pathlib import Path
import pytest
from pydantic import ValidationError
from sebrief.config import Settings
def make_settings(**overrides) -> Settings:
return Settings(_env_file=None, **overrides)
def test_defaults():
s = make_settings()
assert s.minimax_model == "MiniMax-M3"
assert s.minimax_fallback_models == ["MiniMax-M2.7", "MiniMax-M2.5"]
assert s.run_weekday == 0
assert s.run_time_kst == "07:00"
assert s.catchup_window_hours == 72
assert s.max_papers == 40
assert s.backfill_days == 7
assert s.verify_enabled is True
assert s.rss_feeds == []
assert s.db_path == Path("data") / "sebrief.sqlite3"
def test_csv_fields_split():
s = make_settings(
MINIMAX_FALLBACK_MODELS=" a , b ,",
SEBRIEF_RSS_FEEDS="e-Informatica|https://example.org/rss, X|https://x.example/feed",
SEBRIEF_EXTRA_BLACKLIST_ISSNS="1234-5678, 2345-6789",
)
assert s.minimax_fallback_models == ["a", "b"]
assert s.rss_feeds == ["e-Informatica|https://example.org/rss", "X|https://x.example/feed"]
assert s.extra_blacklist_issns == ["1234-5678", "2345-6789"]
def test_run_weekday_validated():
with pytest.raises(ValidationError):
make_settings(SEBRIEF_RUN_WEEKDAY="7")
assert make_settings(SEBRIEF_RUN_WEEKDAY="6").run_weekday == 6
def test_env_aliases(tmp_path):
s = make_settings(SEBRIEF_DATA_DIR=str(tmp_path / "d"), SEBRIEF_MAX_PAPERS="10")
assert s.data_dir == tmp_path / "d"
assert s.max_papers == 10
assert s.db_path == tmp_path / "d" / "sebrief.sqlite3"