import json


def test_handler_missing_total(monkeypatch, lambda_module, context, apigateway_event, payment_token, total):
    """
    Test handler() with a missing total
    """

    def validate_payment_token(payment_token: str, total: int) -> bool:
        # This should never be called
        assert False
        return True

    monkeypatch.setattr(lambda_module, "validate_payment_token", validate_payment_token)

    event = apigateway_event(
        iam="USER_ARN",
        body=json.dumps({
            "paymentToken": payment_token,
        })
    )

    response = lambda_module.handler(event, context)

    assert response["statusCode"] == 400
    assert "body" in response
    body = json.loads(response["body"])
    assert "ok" not in body
    assert "message" in body
    assert isinstance(body["message"], str)
    assert "total" in body["message"]