refactor(pre-alpha): align preview and runtime fixture validation

This commit is contained in:
Bu5hm4nn
2026-03-26 12:11:45 +01:00
parent 68275c4d18
commit 18fd0681ca
4 changed files with 79 additions and 21 deletions

View File

@@ -315,3 +315,43 @@ def test_event_comparison_uses_preset_defaults_only_when_template_slugs_are_omit
"protective-put-90pct-12m",
"ladder-50-50-atm-95pct-12m",
]
with pytest.raises(ValueError, match="at least one template slug"):
service.materialize_scenario(
service.event_preset_service.get_preset("gld-jan-2024-selloff"),
initial_portfolio=BacktestPortfolioState(
currency="USD",
underlying_units=1000.0,
entry_spot=100.0,
loan_amount=68_000.0,
margin_call_ltv=0.75,
),
template_slugs=(),
)
def test_event_comparison_materialize_scenario_rejects_explicit_empty_history() -> None:
provider = SyntheticHistoricalProvider(
source=FakeHistorySource(FIXTURE_HISTORY),
implied_volatility=0.35,
risk_free_rate=0.0,
)
service = EventComparisonService(
provider=provider,
template_service=StrategyTemplateService(),
event_preset_service=EventPresetService(repository=FileEventPresetRepository()),
)
with pytest.raises(ValueError, match="history must not be empty"):
service.materialize_scenario(
service.event_preset_service.get_preset("gld-jan-2024-selloff"),
initial_portfolio=BacktestPortfolioState(
currency="USD",
underlying_units=1000.0,
entry_spot=100.0,
loan_amount=68_000.0,
margin_call_ltv=0.75,
),
template_slugs=("protective-put-atm-12m",),
history=[],
)