From eac5a554f7caa17be7a81e29d7d023e3452ff41d Mon Sep 17 00:00:00 2001 From: gavindiaz Date: Wed, 8 Jul 2026 06:43:53 +0000 Subject: [PATCH] Add pytest conftest --- tests/conftest.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..0743772 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,116 @@ +"""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", + }