SimpleChatbot / hermes_overlay /tests /test_phase4_client_routing.py
Amin
Deploy: HermesFace finalized project to HF Space
2e658e7
Raw
History Blame Contribute Delete
1.46 kB
from __future__ import annotations
import asyncio
import importlib.util
from pathlib import Path
import pytest
import trading.futures_execution as futures_execution
from trading.domain.schema import apply_migrations
@pytest.fixture(autouse=True)
def _db(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
monkeypatch.setenv("TRADING_MODE", "paper")
monkeypatch.setenv("HERMES_EXECUTION_ENABLED", "true")
ok, messages = apply_migrations()
assert ok, messages
def _load_audit_module():
path = Path(__file__).parents[2] / "scripts" / "audit_execution_client_paths.py"
spec = importlib.util.spec_from_file_location("execution_client_path_audit", path)
module = importlib.util.module_from_spec(spec)
assert spec and spec.loader
spec.loader.exec_module(module)
return module
def test_static_client_routing_audit_has_zero_findings():
assert _load_audit_module().audit() == []
def test_retired_raw_entry_api_fails_closed_without_position_mutation():
with pytest.raises(futures_execution.TradingError, match="approved-plan execution API"):
asyncio.run(futures_execution.execute_futures_position(
symbol="BTCUSDT", side="long", leverage=3, size=1.0,
stop_loss=95.0, take_profit=110.0,
orderbook={"asks": [[100.0, 100.0]], "bids": [[99.0, 100.0]]},
))
assert asyncio.run(futures_execution.get_futures_positions())["positions"] == []