from gui_v6.app import bound_local_status
from gui_v6.license_client import LicenseStatus


def test_binding_flags_other_machine():
    st = LicenseStatus(valid=True, status="active", machine_id="AAAA1111")
    out = bound_local_status(st, "BBBB2222")
    assert out.valid is False
    assert out.status == "autre_poste"
    assert "autre poste" in out.message.lower()


def test_binding_ok_same_machine():
    st = LicenseStatus(valid=True, status="active", machine_id="AAAA1111")
    out = bound_local_status(st, "AAAA1111")
    assert out.valid is True
    assert out.status == "active"


def test_binding_noop_without_machine_id():
    st = LicenseStatus(valid=True, status="active", machine_id=None)
    assert bound_local_status(st, "AAAA1111").valid is True


def test_binding_passes_through_invalid_status():
    st = LicenseStatus(valid=False, status="expired", machine_id="OTHER")
    out = bound_local_status(st, "AAAA1111")
    assert out.status == "expired"
    assert out.valid is False
