"""Logika is_export_limited / pv_derating_flags z Deye reg 145 a 179."""

from services.telemetry_collector import _export_limit_flags_from_deye_regs


def test_both_none_unknown() -> None:
    lim, flags = _export_limit_flags_from_deye_regs(None, None)
    assert lim is None and flags is None


def test_solar_sell_disabled() -> None:
    lim, flags = _export_limit_flags_from_deye_regs(0, None)
    assert lim is True and flags == 1


def test_solar_sell_enabled_only() -> None:
    lim, flags = _export_limit_flags_from_deye_regs(1, None)
    assert lim is False and flags == 0


def test_gen_mi_cutoff_bits() -> None:
    lim, flags = _export_limit_flags_from_deye_regs(None, 3)
    assert lim is True and flags == 2


def test_combined_flags() -> None:
    lim, flags = _export_limit_flags_from_deye_regs(0, 3)
    assert lim is True and flags == 3
