| 1234567891011121314151617181920212223242526272829303132333435363738 |
- from datetime import datetime, timezone
- from pathlib import Path
- from argus_mcp.models import MarketQuote, RegimeSnapshot
- from argus_mcp.storage import SnapshotStore
- def test_storage_roundtrip(tmp_path: Path):
- store = SnapshotStore(tmp_path / "argus.sqlite3")
- snapshot = RegimeSnapshot(
- snapshot_id="abc123",
- generated_at=datetime.now(timezone.utc),
- regime="risk_on",
- confidence=0.7,
- summary="Test",
- signals=[MarketQuote(symbol="QQQ", source="test", change_pct=1.0)],
- )
- store.save(snapshot)
- latest = store.latest()
- assert latest is not None
- assert latest.snapshot_id == "abc123"
- assert store.count() == 1
- def test_quote_cache_roundtrip(tmp_path: Path):
- store = SnapshotStore(tmp_path / "argus.sqlite3")
- quote = MarketQuote(symbol="QQQ", source="finnhub", last=500.0, change_pct=1.2)
- store.save_quote(quote, fetched_at=datetime.now(timezone.utc))
- cached = store.latest_quote("QQQ", "finnhub")
- assert cached is not None
- cached_quote, fetched_at = cached
- assert cached_quote.symbol == "QQQ"
- assert cached_quote.source == "finnhub"
- assert fetched_at.tzinfo is not None
|