"""default.toml and portfolio.toml must load cleanly into the expected shapes.""" from __future__ import annotations import pytest pytest.importorskip("pydantic_settings") from pathlib import Path from app.config import load_feeds, load_groups, load_presets ROOT = Path(__file__).resolve().parent.parent DEFAULT = ROOT / "config" / "default.toml" PORTFOLIO = ROOT / "config" / "portfolio.toml" def test_default_groups_present(): g = load_groups(DEFAULT, PORTFOLIO) for expected in ("equity", "mag7", "rates", "macro", "commodities", "fx", "pie"): assert expected in g, f"missing group: {expected}" # Every item is a 3-tuple of strings. for items in g.values(): for sym, lab, note in items: assert isinstance(sym, str) and sym assert isinstance(lab, str) assert isinstance(note, str) def test_default_feeds_present(): f = load_feeds(DEFAULT, PORTFOLIO) for cat in ("markets", "world", "energy", "asia"): assert cat in f, f"missing feed category: {cat}" assert all(name and url for name, url in f[cat]) def test_presets_thesis_present(): p = load_presets(DEFAULT, PORTFOLIO) assert "thesis" in p assert "hormuz" in p["thesis"]