"""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