Files
momentum-system/tests/unit/api/test_snapshot_meta.py
momentum devandClaude Fable 5 cb206e45cb operator-plane: truthful LIVE badge + kill-switch UI + action gating
Badge now derives PAPER/LIVE from broker truth (base-URL host) instead of the
schwab_live literal that read PAPER while go-live swapped only ALPACA_BASE_URL;
live flips body.live-mode (top shimmer -> solid red) with a tooltip of host +
account. Adds the header FLATTEN ALL (two-step arm/confirm, 5s auto-disarm) and
PAUSE ENTRIES toggle (+ amber banner), per-position EXIT buttons (two-step), and
an operator-token field sent as X-Dashboard-Token on every POST (also fixes
approve/reject when a token is set). Action controls gate on
has_execution || command_bus; kill-switch controls on command_bus. No keyboard
shortcut for any destructive action. New styling is :root-token-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 00:19:51 -04:00

42 lines
1.4 KiB
Python

"""Broker-truth LIVE badge + command-bus availability derivation (plan 007 step 4)."""
import pytest
from api.main import _broker_block, _command_bus_enabled
def test_broker_block_paper(monkeypatch):
monkeypatch.setenv("ALPACA_BASE_URL", "https://paper-api.alpaca.markets/v2")
b = _broker_block()
assert b["is_paper"] is True
assert b["base_url_host"] == "paper-api.alpaca.markets"
def test_broker_block_live(monkeypatch):
monkeypatch.setenv("ALPACA_BASE_URL", "https://api.alpaca.markets")
b = _broker_block()
assert b["is_paper"] is False
assert b["base_url_host"] == "api.alpaca.markets"
def test_broker_block_default_is_paper(monkeypatch):
monkeypatch.delenv("ALPACA_BASE_URL", raising=False)
assert _broker_block()["is_paper"] is True
def test_command_bus_needs_token_and_flag(monkeypatch):
monkeypatch.delenv("DASHBOARD_TOKEN", raising=False)
monkeypatch.setenv("COMMAND_BUS_ENABLED", "1")
assert _command_bus_enabled() is False # flag set but no token -> off
monkeypatch.setenv("DASHBOARD_TOKEN", "s3cret")
monkeypatch.delenv("COMMAND_BUS_ENABLED", raising=False)
assert _command_bus_enabled() is False # token set but flag off -> off
monkeypatch.setenv("COMMAND_BUS_ENABLED", "1")
assert _command_bus_enabled() is True
if __name__ == "__main__": # pragma: no cover
pytest.main([__file__, "-q"])