Initial extraction from monorepo
This commit is contained in:
commit
f7ef7ca4ab
56 changed files with 6163 additions and 0 deletions
100
tests/test_cli.py
Normal file
100
tests/test_cli.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
"""CLI smoke tests via click's CliRunner."""
|
||||
from click.testing import CliRunner
|
||||
|
||||
from fire_planner.__main__ import cli
|
||||
|
||||
|
||||
def test_simulate_smoke() -> None:
|
||||
"""Run a tiny scenario through the CLI without writing to DB."""
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"simulate",
|
||||
"--scenario=cyprus-trinity-leave-y3-glide-rising",
|
||||
"--n-paths=200",
|
||||
"--horizon=20",
|
||||
"--spending=100000",
|
||||
"--nw-seed=1000000",
|
||||
"--no-write-db",
|
||||
],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "Scenario: cyprus-trinity-leave-y3-glide-rising" in result.output
|
||||
assert "success_rate" in result.output
|
||||
|
||||
|
||||
def test_simulate_with_underscore_strategy() -> None:
|
||||
"""guyton_klinger contains an underscore — the parser must handle it."""
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"simulate",
|
||||
"--scenario=uk-guyton_klinger-leave-y1-glide-static_60_40",
|
||||
"--n-paths=100",
|
||||
"--horizon=15",
|
||||
"--spending=80000",
|
||||
"--nw-seed=1500000",
|
||||
"--no-write-db",
|
||||
],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "uk-guyton_klinger-leave-y1-glide-static_60_40" in result.output
|
||||
|
||||
|
||||
def test_simulate_bad_scenario_id() -> None:
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["simulate", "--scenario=nope"], catch_exceptions=False)
|
||||
assert result.exit_code != 0
|
||||
|
||||
|
||||
def test_simulate_vpw_floor_with_floor_flag() -> None:
|
||||
"""vpw_floor strategy + --floor=40000 should run without error."""
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"simulate",
|
||||
"--scenario=cyprus-vpw_floor-leave-y2-glide-rising",
|
||||
"--n-paths=200",
|
||||
"--horizon=20",
|
||||
"--spending=60000",
|
||||
"--nw-seed=1500000",
|
||||
"--floor=40000",
|
||||
"--no-write-db",
|
||||
],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "cyprus-vpw_floor" in result.output
|
||||
|
||||
|
||||
def test_simulate_uae_smoke() -> None:
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"simulate",
|
||||
"--scenario=uae-vpw_floor-leave-y2-glide-rising",
|
||||
"--n-paths=200",
|
||||
"--horizon=20",
|
||||
"--spending=60000",
|
||||
"--nw-seed=1500000",
|
||||
"--floor=40000",
|
||||
"--no-write-db",
|
||||
],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "uae-vpw_floor" in result.output
|
||||
|
||||
|
||||
def test_help_lists_commands() -> None:
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["--help"], catch_exceptions=False)
|
||||
assert result.exit_code == 0
|
||||
for cmd in ("ingest", "simulate", "recompute-all", "migrate", "serve"):
|
||||
assert cmd in result.output
|
||||
Loading…
Add table
Add a link
Reference in a new issue