@devries-cameron20 / open-alice / commits / 6deee5f
Fork 0

Alice — an open-source AI trading bot covering equities, crypto, commodities, forex, and macro

Implement tests for demo mode order restrictions

Add tests for demo mode behavior in order API

Cameron “Camo” De Vries committed Nov 6, 2026 at 03:21 UTC 6deee5fd1fe3e74a2221b1719b83c02170774954
1 file changed +38
tests/test_dashboard.py
+38
@@ -48,3 +48,41 @@ def test_chart_payload_all_strategies(sample_ohlcv: pd.DataFrame) -> None:
48 def test_chart_payload_downsamples(sample_ohlcv: pd.DataFrame) -> None:
49 payload = chart_payload(sample_ohlcv, "rsi", max_points=20)
50 assert len(payload["labels"]) <= 20
51 +
52 +
53 +def test_demo_mode_blocks_live_order() -> None:
54 + import os
55 +
56 + os.environ["ALICE_DEMO"] = "1"
57 + try:
58 + from open_alice.dashboard.app import create_dashboard_app
59 +
60 + app = create_dashboard_app()
61 + client = app.test_client()
62 + resp = client.post(
63 + "/api/order",
64 + json={"symbol": "EURUSD", "side": "buy", "volume": 0.01, "live": True},
65 + )
66 + assert resp.status_code == 403
67 + assert "Demo mode" in resp.get_json()["message"]
68 + finally:
69 + del os.environ["ALICE_DEMO"]
70 +
71 +
72 +def test_dry_run_order_still_works_in_demo_mode() -> None:
73 + import os
74 +
75 + os.environ["ALICE_DEMO"] = "1"
76 + try:
77 + from open_alice.dashboard.app import create_dashboard_app
78 +
79 + app = create_dashboard_app()
80 + client = app.test_client()
81 + resp = client.post(
82 + "/api/order",
83 + json={"symbol": "EURUSD", "side": "buy", "volume": 0.01},
84 + )
85 + assert resp.status_code == 200
86 + assert "DRY RUN" in resp.get_json()["message"]
87 + finally:
88 + del os.environ["ALICE_DEMO"]