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
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'