from scripts.portfolios._defs import PORTFOLIOS


def test_six_portfolios_defined():
    assert set(PORTFOLIOS) == {"PORT01", "PORT02", "PORT03", "PORT04", "PORT05", "PORT06"}


def test_port06_is_master_shape_cap():
    p = PORTFOLIOS["PORT06"]
    sids = set(p.sleeve_ids)
    assert {"SH_BTC", "SH_ETH", "TSM01", "PR_ETHBTC", "PR_ETHBTC_15M", "XS01"} <= sids
    # 19 dal 2026-06-09: + XS01 (reversione cross-sectional 8 asset, sleeve PAPER, family XSEC)
    assert len(sids) == 19
    # SHAPE cappata a 0.0588 (2026-06-05): SH01 senza SL by-design, esposizione dimezzata
    # (ricerca sh01_exit_lab: 11 famiglie di stop, 0 sopravvissute)
    assert p.weighting == "cap" and p.caps == {"PAIRS": 0.33, "SHAPE": 0.0588}


def test_default_leverage_sober():
    assert PORTFOLIOS["PORT06"].leverage == 2.0
