from fxhnt.application.paper_book import _regime_lookback

def test_late_joining_sleeve_does_not_zero_bias_regime():
    # 'a' alone has a rising-vol regime over 60 days -> L_t < 60.
    calm = [0.005, -0.005] * 25; hot = [0.05, -0.05] * 5
    a = {i + 1: v for i, v in enumerate(calm + hot)}
    assert _regime_lookback({"a": a}, ["a"]) < 60
    # 'b' joins only for the last 10 days. Zero-filling its first 50 days would distort the pooled
    # mean's vol; NaN-aware ignores the missing cells, so the regime is still detected (L_t < 60).
    b = {i + 1: (0.005 if i % 2 else -0.005) for i in range(50, 60)}
    assert _regime_lookback({"a": a, "b": b}, ["a", "b"]) < 60

def test_all_calm_holds_l_max():
    flat = {i + 1: (0.01 if i % 2 else -0.01) for i in range(60)}
    assert _regime_lookback({"a": flat}, ["a"]) == 60
