def test_does_not_create_payment(self):
     count = RecurringPayment.objects.count()
     account = Account.objects.get(pk=2)
     try:
         RecurringPayment.create(
             account = account, 
             amount = '', 
             card_number = '', 
             card_expires = date.today(), 
             first_name = '', 
             last_name = '',
             error = PaymentRequestError,
         )
         assert False
     except PaymentRequestError:
         pass
     
     assert count == RecurringPayment.objects.count()
     
     assert recurring_payment.gateway.start_payment_called
     assert not recurring_payment.gateway.change_payment_called
     assert not recurring_payment.gateway.cancel_payment_called
Example #2
0
def account_has_payment_method(client, parameters):
    """
    Create a payment method for the first account.
    """
    account_has_no_payment_method(client, parameters)
    Account.objects.get(pk=1).recurring_payment = RecurringPayment(
        name='Bob Jones',
        period=1,
        amount='$10.00',
        number='********1234',
        token=2,
        gateway_token='1000',
        active_on=PAYMENT_START,
    )
    return client, parameters
 def test_creates_payment(self):
     account = Account.objects.get(pk=2)
     payment = RecurringPayment.create(
         account = account, 
         amount = 2999, 
         card_number = '4111111111111111', 
         card_expires = date.today(), 
         first_name = 'Bob', 
         last_name = 'Jones',
         error = None,
     )
     
     assert recurring_payment.gateway.start_payment_called
     assert not recurring_payment.gateway.change_payment_called
     assert not recurring_payment.gateway.cancel_payment_called
     
     assert payment.name == "Bob Jones"
     assert payment.number == '************1111'
     assert payment.amount == '$29.99'
     assert payment.account == account
     assert payment.period == 1
     assert payment.token == '2'
     assert payment.gateway_token == '1000'