Esempio n. 1
0
def test_refund_invalid_data(
        mocked_gateway,
        mocked_logger,
        charged_payment,
        razorpay_success_response,
        gateway_params):

    # Assign the side effect to the gateway's `refund()` method,
    # that should trigger the expected error.
    mocked_gateway.return_value.payment.refund.side_effect = ServerError()

    # Attempt charging
    payment_info = create_payment_information(
        charged_payment, amount=TRANSACTION_AMOUNT)
    response = refund(payment_info, gateway_params)

    # Ensure a error was returned
    assert response['error'] == errors.SERVER_ERROR
    assert not response['is_success']

    # Ensure the transaction is correctly set
    assert response['kind'] == TransactionKind.REFUND

    # Ensure the HTTP error was logged
    assert mocked_logger.call_count == 1
Esempio n. 2
0
def test_refund_invalid_data(mocked_gateway, mocked_logger, charged_payment,
                             razorpay_success_response, gateway_params):

    # Assign the side effect to the gateway's `refund()` method,
    # that should trigger the expected error.
    mocked_gateway.return_value.payment.refund.side_effect = ServerError()

    # Attempt charging
    txn, error = refund(charged_payment, TRANSACTION_AMOUNT, **gateway_params)

    # Ensure a error was returned
    assert error == errors.SERVER_ERROR
    assert not txn.is_success

    # Ensure the transaction is correctly set
    assert txn.payment == charged_payment
    assert txn.kind == TransactionKind.REFUND

    # Ensure the HTTP error was logged
    assert mocked_logger.call_count == 1