115 lines
4.4 KiB
Python
115 lines
4.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple test to verify all 10 exchange connectors are properly implemented.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Add the current directory to Python path
|
|
sys.path.insert(0, os.path.abspath('.'))
|
|
|
|
def test_all_connectors():
|
|
"""Test that all 10 exchange connectors can be imported and initialized."""
|
|
|
|
print("=== Testing All 10 Exchange Connectors ===\n")
|
|
|
|
connectors = {}
|
|
|
|
try:
|
|
# Import all connectors
|
|
from COBY.connectors.binance_connector import BinanceConnector
|
|
from COBY.connectors.coinbase_connector import CoinbaseConnector
|
|
from COBY.connectors.kraken_connector import KrakenConnector
|
|
from COBY.connectors.bybit_connector import BybitConnector
|
|
from COBY.connectors.okx_connector import OKXConnector
|
|
from COBY.connectors.huobi_connector import HuobiConnector
|
|
from COBY.connectors.kucoin_connector import KuCoinConnector
|
|
from COBY.connectors.gateio_connector import GateIOConnector
|
|
from COBY.connectors.bitfinex_connector import BitfinexConnector
|
|
from COBY.connectors.mexc_connector import MEXCConnector
|
|
|
|
# Initialize all connectors
|
|
connectors = {
|
|
'binance': BinanceConnector(),
|
|
'coinbase': CoinbaseConnector(use_sandbox=True),
|
|
'kraken': KrakenConnector(),
|
|
'bybit': BybitConnector(use_testnet=True),
|
|
'okx': OKXConnector(use_demo=True),
|
|
'huobi': HuobiConnector(),
|
|
'kucoin': KuCoinConnector(use_sandbox=True),
|
|
'gateio': GateIOConnector(use_testnet=True),
|
|
'bitfinex': BitfinexConnector(),
|
|
'mexc': MEXCConnector()
|
|
}
|
|
|
|
print("✅ All connectors imported successfully!\n")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Failed to import connectors: {e}")
|
|
return False
|
|
|
|
# Test each connector
|
|
success_count = 0
|
|
total_count = len(connectors)
|
|
|
|
for name, connector in connectors.items():
|
|
try:
|
|
print(f"Testing {name.upper()} connector:")
|
|
|
|
# Test basic properties
|
|
assert connector.exchange_name == name
|
|
assert hasattr(connector, 'websocket_url')
|
|
assert hasattr(connector, 'message_handlers')
|
|
assert hasattr(connector, 'subscriptions')
|
|
print(f" ✓ Basic properties: OK")
|
|
|
|
# Test symbol normalization
|
|
btc_symbol = connector.normalize_symbol('BTCUSDT')
|
|
eth_symbol = connector.normalize_symbol('ETHUSDT')
|
|
print(f" ✓ Symbol normalization: BTCUSDT -> {btc_symbol}, ETHUSDT -> {eth_symbol}")
|
|
|
|
# Test required methods exist
|
|
required_methods = [
|
|
'connect', 'disconnect', 'subscribe_orderbook', 'subscribe_trades',
|
|
'unsubscribe_orderbook', 'unsubscribe_trades', 'get_symbols',
|
|
'get_orderbook_snapshot', 'get_connection_status'
|
|
]
|
|
|
|
for method in required_methods:
|
|
assert hasattr(connector, method), f"Missing method: {method}"
|
|
assert callable(getattr(connector, method)), f"Method not callable: {method}"
|
|
print(f" ✓ Required methods: All {len(required_methods)} methods present")
|
|
|
|
# Test statistics
|
|
stats = connector.get_stats()
|
|
assert isinstance(stats, dict)
|
|
assert 'exchange' in stats
|
|
assert stats['exchange'] == name
|
|
print(f" ✓ Statistics: {len(stats)} fields")
|
|
|
|
# Test connection status
|
|
status = connector.get_connection_status()
|
|
print(f" ✓ Connection status: {status.value}")
|
|
|
|
print(f" ✅ {name.upper()} connector: ALL TESTS PASSED\n")
|
|
success_count += 1
|
|
|
|
except Exception as e:
|
|
print(f" ❌ {name.upper()} connector: FAILED - {e}\n")
|
|
|
|
print(f"=== SUMMARY ===")
|
|
print(f"Total connectors: {total_count}")
|
|
print(f"Successful: {success_count}")
|
|
print(f"Failed: {total_count - success_count}")
|
|
|
|
if success_count == total_count:
|
|
print("🎉 ALL 10 EXCHANGE CONNECTORS WORKING PERFECTLY!")
|
|
return True
|
|
else:
|
|
print(f"⚠️ {total_count - success_count} connectors need attention")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = test_all_connectors()
|
|
sys.exit(0 if success else 1) |