Spaces:
Sleeping
Sleeping
File size: 2,328 Bytes
b9c68d4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | """Unit tests configuration and fixtures."""
import pytest
from unittest.mock import Mock, patch, MagicMock
@pytest.fixture
def mock_logger():
"""Mock logger for unit tests."""
return Mock()
@pytest.fixture
def mock_config():
"""Mock configuration object."""
config = Mock()
config.DATABASE_URL = ':memory:'
config.LOG_LEVEL = 'DEBUG'
config.CACHE_SIZE = 100
config.API_TIMEOUT = 30
return config
@pytest.fixture
def mock_market_processor():
"""Mock AdvancedMarketProcessor for unit tests."""
with patch('src.core.advanced_market_processing.AdvancedMarketProcessor') as mock:
processor = Mock()
processor.process_data.return_value = {'processed': True}
processor.analyze_trends.return_value = {'trend': 'bullish'}
mock.return_value = processor
yield processor
@pytest.fixture
def mock_voting_system():
"""Mock VotingStrategy for unit tests."""
with patch('src.ai.voting_system.VotingStrategy') as mock:
voting = Mock()
voting.vote.return_value = {'decision': 'buy', 'confidence': 0.8}
mock.return_value = voting
yield voting
@pytest.fixture
def mock_sentiment_analyzer():
"""Mock sentiment analyzer."""
analyzer = Mock()
analyzer.analyze.return_value = {
'sentiment': 'positive',
'score': 0.85,
'confidence': 0.9
}
return analyzer
@pytest.fixture
def mock_fibonacci_analyzer():
"""Mock Fibonacci analyzer."""
analyzer = Mock()
analyzer.calculate_levels.return_value = {
'support': [100, 95, 90],
'resistance': [110, 115, 120]
}
return analyzer
@pytest.fixture
def sample_price_data():
"""Sample price data for testing."""
return {
'prices': [100, 102, 98, 105, 103, 107, 104],
'volumes': [1000, 1200, 800, 1500, 1100, 1300, 900],
'timestamps': ['2024-01-01', '2024-01-02', '2024-01-03',
'2024-01-04', '2024-01-05', '2024-01-06', '2024-01-07']
}
@pytest.fixture
def mock_database_logger():
"""Mock database logger."""
with patch('src.core.database_logger.DatabaseLogger') as mock:
logger = Mock()
logger.log.return_value = True
logger.get_logs.return_value = []
mock.return_value = logger
yield logger |