Add sys import to test files and remove obsolete integration tests
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 9s
Blockchain Synchronization Verification / sync-verification (push) Failing after 1s
CLI Tests / test-cli (push) Failing after 3s
Documentation Validation / validate-docs (push) Successful in 6s
Documentation Validation / validate-policies-strict (push) Successful in 2s
Integration Tests / test-service-integration (push) Successful in 40s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 1s
P2P Network Verification / p2p-verification (push) Successful in 2s
Production Tests / Production Integration Tests (push) Successful in 21s
Python Tests / test-python (push) Successful in 13s
Security Scanning / security-scan (push) Failing after 46s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 17s
Smart Contract Tests / lint-solidity (push) Successful in 10s
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 9s
Blockchain Synchronization Verification / sync-verification (push) Failing after 1s
CLI Tests / test-cli (push) Failing after 3s
Documentation Validation / validate-docs (push) Successful in 6s
Documentation Validation / validate-policies-strict (push) Successful in 2s
Integration Tests / test-service-integration (push) Successful in 40s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 1s
P2P Network Verification / p2p-verification (push) Successful in 2s
Production Tests / Production Integration Tests (push) Successful in 21s
Python Tests / test-python (push) Successful in 13s
Security Scanning / security-scan (push) Failing after 46s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 17s
Smart Contract Tests / lint-solidity (push) Successful in 10s
- Add sys import to 29 test files across agent-coordinator, blockchain-event-bridge, blockchain-node, and coordinator-api - Remove apps/blockchain-event-bridge/tests/test_integration.py (obsolete bridge integration tests) - Remove apps/coordinator-api/tests/test_integration.py (obsolete API integration tests) - Implement GPU registration in marketplace_gpu.py with GPURegistry model persistence
This commit is contained in:
142
apps/exchange/tests/test_edge_cases_exchange.py
Normal file
142
apps/exchange/tests/test_edge_cases_exchange.py
Normal file
@@ -0,0 +1,142 @@
|
||||
"""Edge case and error handling tests for exchange service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from exchange_api import OrderCreate, OrderResponse, TradeResponse, OrderBookResponse
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_create_empty_type():
|
||||
"""Test OrderCreate with empty order type"""
|
||||
order = OrderCreate(
|
||||
order_type="",
|
||||
amount=100.0,
|
||||
price=0.00001
|
||||
)
|
||||
assert order.order_type == ""
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_create_zero_amount():
|
||||
"""Test OrderCreate with zero amount"""
|
||||
order = OrderCreate(
|
||||
order_type="BUY",
|
||||
amount=0.0,
|
||||
price=0.00001
|
||||
)
|
||||
assert order.amount == 0.0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_create_negative_price():
|
||||
"""Test OrderCreate with negative price"""
|
||||
order = OrderCreate(
|
||||
order_type="BUY",
|
||||
amount=100.0,
|
||||
price=-0.00001
|
||||
)
|
||||
assert order.price == -0.00001
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_response_zero_remaining():
|
||||
"""Test OrderResponse with zero remaining"""
|
||||
order = OrderResponse(
|
||||
id=1,
|
||||
order_type="BUY",
|
||||
amount=100.0,
|
||||
price=0.00001,
|
||||
total=0.001,
|
||||
filled=100.0,
|
||||
remaining=0.0,
|
||||
status="FILLED",
|
||||
created_at=datetime.utcnow()
|
||||
)
|
||||
assert order.remaining == 0.0
|
||||
assert order.status == "FILLED"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_response_empty_status():
|
||||
"""Test OrderResponse with empty status"""
|
||||
order = OrderResponse(
|
||||
id=1,
|
||||
order_type="BUY",
|
||||
amount=100.0,
|
||||
price=0.00001,
|
||||
total=0.001,
|
||||
filled=0.0,
|
||||
remaining=100.0,
|
||||
status="",
|
||||
created_at=datetime.utcnow()
|
||||
)
|
||||
assert order.status == ""
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_trade_response_zero_amount():
|
||||
"""Test TradeResponse with zero amount"""
|
||||
trade = TradeResponse(
|
||||
id=1,
|
||||
amount=0.0,
|
||||
price=0.00001,
|
||||
total=0.0,
|
||||
created_at=datetime.utcnow()
|
||||
)
|
||||
assert trade.amount == 0.0
|
||||
assert trade.total == 0.0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_book_empty_buys():
|
||||
"""Test OrderBookResponse with empty buys"""
|
||||
orderbook = OrderBookResponse(buys=[], sells=[])
|
||||
assert len(orderbook.buys) == 0
|
||||
assert len(orderbook.sells) == 0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_book_empty_sells():
|
||||
"""Test OrderBookResponse with empty sells"""
|
||||
from datetime import datetime
|
||||
buy_order = OrderResponse(
|
||||
id=1,
|
||||
order_type="BUY",
|
||||
amount=100.0,
|
||||
price=0.00001,
|
||||
total=0.001,
|
||||
filled=0.0,
|
||||
remaining=100.0,
|
||||
status="OPEN",
|
||||
created_at=datetime.utcnow()
|
||||
)
|
||||
orderbook = OrderBookResponse(buys=[buy_order], sells=[])
|
||||
assert len(orderbook.buys) == 1
|
||||
assert len(orderbook.sells) == 0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_create_very_large_amount():
|
||||
"""Test OrderCreate with very large amount"""
|
||||
order = OrderCreate(
|
||||
order_type="BUY",
|
||||
amount=9999999999.0,
|
||||
price=0.00001
|
||||
)
|
||||
assert order.amount == 9999999999.0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_order_create_very_small_price():
|
||||
"""Test OrderCreate with very small price"""
|
||||
order = OrderCreate(
|
||||
order_type="BUY",
|
||||
amount=100.0,
|
||||
price=0.000000001
|
||||
)
|
||||
assert order.price == 0.000000001
|
||||
Reference in New Issue
Block a user