Files
2026-07-08 06:43:53 +00:00

117 lines
2.7 KiB
Python

"""Pytest configuration and fixtures."""
import os
import sys
import pytest
# Add the project root to sys.path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@pytest.fixture
def exchange_config():
"""Standard test configuration."""
return {
"apiKey": "test-key-12345678",
"host": "http://mock-mt5bridge:8080",
"symbols": {
"XAU/USD": "XAUUSDc",
"EUR/USD": "EURUSDc",
},
}
@pytest.fixture
def mock_account():
return {
"data": [{
"login": 12345678,
"leverage": 100,
"trade_allowed": True,
"trade_expert": True,
"currency": "USD",
"server": "TestServer",
"name": "Test Account",
"company": "Test Broker",
"balance": 10000.0,
"equity": 10100.0,
"profit": 100.0,
"margin": 500.0,
"margin_free": 9600.0,
"margin_level": 2020.0,
}],
"count": 1,
"format": "json",
}
@pytest.fixture
def mock_ticker():
return {
"data": [{
"time": "2026-07-08T12:00:00",
"bid": 4180.50,
"ask": 4181.00,
"last": 4180.75,
"volume": 100,
"flags": 6,
"volume_real": 100.0,
}],
"count": 1,
"format": "json",
}
@pytest.fixture
def mock_bars():
return {
"data": [
{"time": "2026-07-08T11:00:00", "open": 4180.0, "high": 4185.0,
"low": 4178.0, "close": 4182.0, "tick_volume": 100, "spread": 5,
"real_volume": 50.0},
{"time": "2026-07-08T12:00:00", "open": 4182.0, "high": 4186.0,
"low": 4180.0, "close": 4184.0, "tick_volume": 120, "spread": 5,
"real_volume": 60.0},
],
"count": 2,
"format": "json",
}
@pytest.fixture
def mock_positions():
return {
"data": [
{
"ticket": 1001,
"symbol": "XAUUSDc",
"type": 0, # buy
"volume": 0.01,
"price_open": 4180.0,
"sl": 4170.0,
"tp": 4190.0,
"price_current": 4185.0,
"swap": 0.0,
"profit": 0.5,
"comment": "test",
"magic": 12345,
},
],
"count": 1,
"format": "json",
}
@pytest.fixture
def mock_order_result():
return {
"data": {
"retcode": 10009,
"order": 2001,
"comment": "Request executed",
},
"count": 1,
"format": "json",
}