コード例 #1
0
def test_ExpensivePaymentGatewayRetriesOnCheapOne(mocker):
    amount = 25.23
    payment = Payment(creditCardNumber, cardHolder, expirationDate, securityCode, amount)
    mocked_func = mocker.patch('expensivePaymentGateway.ExpensivePaymentGateway.processPayment')
    mocked_func2 = mocker.patch('cheapPaymentGateway.CheapPaymentGateway.processPayment')
    payment.process()
    mocked_func.assert_called()
    mocked_func2.assert_called()
コード例 #2
0
def ProcessPayment():
    data = request.form
    creditCardNumber, cardHolder, expirationDate, securityCode, amount = SanitizeParameters(
        data)
    try:
        payment = Payment(creditCardNumber, cardHolder, expirationDate,
                          securityCode, amount)
        print("uptest")
        result = payment.process()
        print("test")
        if result.status_code == 200:
            return "Payment is processed : 200 OK", 200
    except (TypeError, ValueError) as e:
        return "The request is invalid: 400 bad request", 400
    except:
        return "500 internal server error", 500
    return "500 internal server error", 500
コード例 #3
0
def test_PremiumPaymentGatewayRetriesThreeTimes(mocker):
    amount = 521.25
    payment = Payment(creditCardNumber, cardHolder, expirationDate, securityCode, amount)
    mocked_func = mocker.patch('premiumPaymentGateway.PremiumPaymentGateway.processPayment')
    payment.process()
    assert len(mocked_func.call_args_list) == 4
コード例 #4
0
def test_CorrectGatewayIsUsedForOver500GBP(mocker):
    amount = 521.25
    payment = Payment(creditCardNumber, cardHolder, expirationDate, securityCode, amount)
    mocked_func = mocker.patch('premiumPaymentGateway.PremiumPaymentGateway.processPayment')
    payment.process()
    mocked_func.assert_called()
コード例 #5
0
def test_CorrectGatewayIsUsedFor21_500GBP(mocker):
    amount = 21.3
    payment = Payment(creditCardNumber, cardHolder, expirationDate, securityCode, amount)
    mocked_func = mocker.patch('expensivePaymentGateway.ExpensivePaymentGateway.processPayment')
    payment.process()
    mocked_func.assert_called()
コード例 #6
0
def test_CorrectGatewayIsUsedForLessThan20GBP(mocker):
    amount = 19.5
    payment = Payment(creditCardNumber, cardHolder, expirationDate, securityCode, amount)
    mocked_func = mocker.patch('cheapPaymentGateway.CheapPaymentGateway.processPayment')
    payment.process()
    mocked_func.assert_called()