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

@@ -11,6 +11,13 @@ from app.services.event_comparison_ui import EventComparisonFixtureHistoricalPri
def test_event_comparison_page_service_accepts_string_and_decimal_boundary_values() -> None:
service = EventComparisonPageService()
preview = service.preview_scenario(
preset_slug="gld-jan-2024-selloff",
template_slugs=("protective-put-atm-12m",),
underlying_units="1000.0",
loan_amount=Decimal("68000.0"),
margin_call_ltv="0.75",
)
report = service.run_read_only_comparison(
preset_slug="gld-jan-2024-selloff",
template_slugs=("protective-put-atm-12m", "protective-put-95pct-12m"),
@@ -19,6 +26,9 @@ def test_event_comparison_page_service_accepts_string_and_decimal_boundary_value
margin_call_ltv="0.75",
)
assert preview.initial_portfolio.underlying_units == 1000.0
assert preview.initial_portfolio.loan_amount == 68000.0
assert preview.initial_portfolio.margin_call_ltv == 0.75
assert report.scenario.initial_portfolio.underlying_units == 1000.0
assert report.scenario.initial_portfolio.loan_amount == 68000.0
assert report.scenario.initial_portfolio.margin_call_ltv == 0.75

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()