"""Tests for Bollinger Bands mean reversion strategy."""

import pytest
from decimal import Decimal
from src.strategies.technical.bollinger_mean_reversion import BollingerMeanReversionStrategy
from src.strategies.base import SignalType


class TestBollingerMeanReversionStrategy:
    """Tests for BollingerMeanReversionStrategy."""
    
    @pytest.fixture
    def strategy(self):
        """Create Bollinger mean reversion strategy instance."""
        return BollingerMeanReversionStrategy(
            name="test_bollinger_mr",
            parameters={
                'period': 20,
                'std_dev': 2.0,
                'trend_filter': True,
                'trend_ma_period': 50,
                'entry_threshold': 0.95,
                'exit_threshold': 0.5
            }
        )
    
    def test_initialization(self, strategy):
        """Test strategy initialization."""
        assert strategy.period == 20
        assert strategy.std_dev == 2.0
        assert strategy.trend_filter is True
        assert strategy.trend_ma_period == 50
        assert strategy.entry_threshold == 0.95
        assert strategy.exit_threshold == 0.5
    
    def test_on_tick_insufficient_data(self, strategy):
        """Test that strategy returns None with insufficient data."""
        signal = strategy.on_tick(
            symbol="BTC/USD",
            price=Decimal("50000"),
            timeframe="1h",
            data={'volume': 1000}
        )
        assert signal is None
    
    def test_position_tracking(self, strategy):
        """Test position tracking."""
        assert strategy._in_position is False
        assert strategy._entry_price is None
    
    def test_strategy_metadata(self, strategy):
        """Test strategy metadata."""
        assert strategy.name == "test_bollinger_mr"
        assert strategy.enabled is False

