fix(CORE-001D): close boundary review gaps
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user