"""期权买入流动性门禁:真实卖一价+深度."""
from lib.exchange.okx_options_lib import (
    cap_option_buy_sheets_to_ask_depth,
    option_buy_liquidity_ok,
)


def test_option_buy_liquidity_ok_requires_ask_and_depth():
    assert option_buy_liquidity_ok(10, 1)[0] is True
    assert option_buy_liquidity_ok(10, 0)[0] is False
    assert option_buy_liquidity_ok(10, None)[0] is False
    assert option_buy_liquidity_ok(None, 5)[0] is False
    assert option_buy_liquidity_ok(0, 5)[0] is False


def test_cap_option_buy_sheets_to_ask_depth():
    capped, msg = cap_option_buy_sheets_to_ask_depth(9, 2.8, min_sz=1)
    assert capped == 2
    assert msg == ""
    capped, msg = cap_option_buy_sheets_to_ask_depth(1, 0.4, min_sz=1)
    assert capped is None
    assert "深度不足" in msg
