30 lines
852 B
Python
30 lines
852 B
Python
"""Tests for Part XI: Historical scenario presets."""
|
|
|
|
from fqbm.scenarios import get_scenario, list_scenarios
|
|
from fqbm.workbook.runner import run_workbook
|
|
|
|
|
|
def test_list_scenarios():
|
|
names = list_scenarios()
|
|
assert "asia_1997" in names
|
|
assert "gfc_2008" in names
|
|
assert "pandemic_2020" in names
|
|
assert "rate_shock_2022" in names
|
|
|
|
|
|
def test_get_scenario():
|
|
p = get_scenario("asia_1997")
|
|
assert p is not None
|
|
assert p.name == "asia_1997"
|
|
assert p.state.R == 80
|
|
assert get_scenario("nonexistent") is None
|
|
|
|
|
|
def test_run_workbook_with_scenario():
|
|
result = run_workbook(scenario="asia_1997", mc_runs=3)
|
|
assert result["state"].R == 80
|
|
assert "dashboard" in result
|
|
result2 = run_workbook(scenario="gfc_2008", mc_runs=2)
|
|
assert result2["state"].Loans == 2200
|
|
assert result2["state"].E_b == 80
|