"""
Unit tests for MultiTimeframeEngine
"""
import pytest
from python.analytics.multi_timeframe import MultiTimeframeEngine

def test_single_timeframe_evaluation():
    tf = MultiTimeframeEngine.evaluate_timeframe(
        ltp=24500.0,
        vwap=24450.0,
        ema_20=24470.0,
        ema_50=24400.0,
        rsi=62.0,
        supertrend_dir=1
    )
    assert tf["bias"] == "STRONG_BULLISH"
    assert tf["alignment_score"] >= 3

def test_timeframe_alignment_matrix_full_confluence():
    matrix = MultiTimeframeEngine.build_alignment_matrix(
        htf_bias="STRONG_BULLISH",
        itf_bias="MILD_BULLISH",
        ltf_bias="STRONG_BULLISH"
    )
    assert matrix["matrix_state"] == "FULL_BULLISH_CONFLUENCE"
    assert matrix["confluence_recommendation"] == "FAVOR_BUY_CE"
    assert matrix["is_aligned"] is True

def test_timeframe_alignment_matrix_conflicted():
    matrix = MultiTimeframeEngine.build_alignment_matrix(
        htf_bias="STRONG_BULLISH",
        itf_bias="MILD_BEARISH",
        ltf_bias="MILD_BEARISH"
    )
    assert matrix["matrix_state"] == "HTF_BULLISH_LTF_PULLBACK"
    assert matrix["confluence_recommendation"] == "WAIT_FOR_LTF_CONFIRMATION"
    assert matrix["is_aligned"] is False
