Files
aitbc/apps/stubs/exchange-integration/tests/test_unit_exchange_integration.py
aitbc 3897bcbf24
Some checks failed
CLI Tests / test-cli (push) Failing after 4s
Deploy to Testnet / deploy-testnet (push) Successful in 1m40s
Documentation Validation / validate-docs (push) Failing after 12s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 2m42s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 34s
Package Tests / Python package - aitbc-core (push) Successful in 27s
Package Tests / Python package - aitbc-crypto (push) Successful in 13s
Package Tests / Python package - aitbc-sdk (push) Successful in 16s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 18s
Python Tests / test-python (push) Failing after 50s
Security Scanning / security-scan (push) Failing after 43s
Multi-Node Stress Testing / stress-test (push) Successful in 12s
Cross-Node Transaction Testing / transaction-test (push) Successful in 9s
refactor: move version to separate module and improve logging
- Created aitbc/_version.py with centralized version definition
- Updated aitbc/__init__.py to import __version__ from _version module
- Updated constants.py to use __version__ for PACKAGE_VERSION
- Replaced print() calls with logger in decorators.py, events.py, queue_manager.py, and state.py
- Added logger initialization using get_logger(__name__) in config.py, decorators.py, events.py, queue_manager.py, and state.py
- Added cli/commands
2026-05-11 20:12:01 +02:00

102 lines
2.6 KiB
Python

"""Unit tests for exchange integration service"""
import pytest
import sys
import sys
from pathlib import Path
from unittest.mock import Mock, patch
# Mock aiohttp before importing
sys.modules['aiohttp'] = Mock()
from main import app, ExchangeRegistration, TradingPair, OrderRequest
@pytest.mark.unit
def test_app_initialization():
"""Test that the FastAPI app initializes correctly"""
assert app is not None
assert app.title == "AITBC Exchange Integration Service"
assert app.version == "1.0.0"
@pytest.mark.unit
def test_exchange_registration_model():
"""Test ExchangeRegistration model"""
registration = ExchangeRegistration(
name="TestExchange",
api_key="test_key_123",
sandbox=True,
description="Test exchange"
)
assert registration.name == "TestExchange"
assert registration.api_key == "test_key_123"
assert registration.sandbox is True
assert registration.description == "Test exchange"
@pytest.mark.unit
def test_exchange_registration_defaults():
"""Test ExchangeRegistration default values"""
registration = ExchangeRegistration(
name="TestExchange",
api_key="test_key_123"
)
assert registration.name == "TestExchange"
assert registration.api_key == "test_key_123"
assert registration.sandbox is True
assert registration.description is None
@pytest.mark.unit
def test_trading_pair_model():
"""Test TradingPair model"""
pair = TradingPair(
symbol="AITBC/BTC",
base_asset="AITBC",
quote_asset="BTC",
min_order_size=0.001,
price_precision=8,
quantity_precision=6
)
assert pair.symbol == "AITBC/BTC"
assert pair.base_asset == "AITBC"
assert pair.quote_asset == "BTC"
assert pair.min_order_size == 0.001
assert pair.price_precision == 8
assert pair.quantity_precision == 6
@pytest.mark.unit
def test_order_request_model():
"""Test OrderRequest model"""
order = OrderRequest(
symbol="AITBC/BTC",
side="buy",
type="limit",
quantity=100.0,
price=0.00001
)
assert order.symbol == "AITBC/BTC"
assert order.side == "buy"
assert order.type == "limit"
assert order.quantity == 100.0
assert order.price == 0.00001
@pytest.mark.unit
def test_order_request_market_order():
"""Test OrderRequest for market order"""
order = OrderRequest(
symbol="AITBC/BTC",
side="sell",
type="market",
quantity=50.0
)
assert order.symbol == "AITBC/BTC"
assert order.side == "sell"
assert order.type == "market"
assert order.quantity == 50.0
assert order.price is None