fix(CORE-001D): close boundary review gaps

This commit is contained in:
Bu5hm4nn
2026-03-26 17:34:09 +01:00
parent 94f3c1ef83
commit bdf56ecebe
4 changed files with 70 additions and 12 deletions

View File

@@ -75,6 +75,35 @@ async def test_price_feed_discards_malformed_cached_payload_and_refetches(monkey
assert feed._cache.writes[0][0] == "price:GLD"
@pytest.mark.asyncio
async def test_price_feed_discards_cached_payload_missing_required_price_and_refetches(
monkeypatch: pytest.MonkeyPatch,
) -> None:
feed = PriceFeed()
feed._cache = _CacheStub({"price:GLD": {"symbol": "GLD", "timestamp": "2026-03-26T12:00:00+00:00"}})
async def fake_fetch(symbol: str):
return {
"symbol": symbol,
"price": 205.0,
"currency": "USD",
"timestamp": datetime(2026, 3, 26, 12, 3, tzinfo=timezone.utc),
"source": "yfinance",
}
monkeypatch.setattr(feed, "_fetch_yfinance", fake_fetch)
data = await feed.get_price("GLD")
assert data == PriceData(
symbol="GLD",
price=205.0,
currency="USD",
timestamp=datetime(2026, 3, 26, 12, 3, tzinfo=timezone.utc),
source="yfinance",
)
@pytest.mark.asyncio
async def test_price_feed_rejects_invalid_provider_payload() -> None:
feed = PriceFeed()