from app.workflow_guard import _last_action_invoice_sent_evidence


def test_last_action_send_invoice_is_evidence_when_invoice_exists_and_no_pending_task():
    opp = {"last_action_code": "SEND_INVOICE"}
    assert _last_action_invoice_sent_evidence(opp, 1, []) is True


def test_last_action_send_invoice_rejects_pending_invoice_task():
    opp = {"last_action_code": "SEND_INVOICE"}
    tasks = [
        {
            "action_code": "SEND_INVOICE",
            "action": "Enviar fatura ao cliente",
            "status": "pending",
        }
    ]
    assert _last_action_invoice_sent_evidence(opp, 1, tasks) is False


def test_last_action_send_invoice_requires_invoice():
    opp = {"last_action_code": "SEND_INVOICE"}
    assert _last_action_invoice_sent_evidence(opp, 0, []) is False
