示例#1
0
    def test_working_process_request(self, mock_create):
        transaction_id = 'stripe_charge_id'
        mock_create.return_value = StripeObject(id=transaction_id)

        self._call_process_request()

        self.assertEqual(PaymentRecord.objects.count(), 1)
        self.assertEqual(PaymentRecord.objects.all()[0].transaction_id, transaction_id)
        self.assertEqual(mock_create.call_count, 1)
示例#2
0
    def test_pay_autopayable_invoices(self, fake_charge, fake_customer):
        self._create_autopay_method(fake_customer)
        fake_charge.return_value = StripeObject(id='transaction_id')

        original_outbox_length = len(mail.outbox)

        autopayable_invoice = Invoice.objects.filter(
            subscription=self.subscription)
        date_due = autopayable_invoice.first().date_due

        AutoPayInvoicePaymentHandler().pay_autopayable_invoices(date_due)
        self.assertAlmostEqual(autopayable_invoice.first().get_total(), 0)
        self.assertEqual(len(PaymentRecord.objects.all()), 1)
        self.assertEqual(len(mail.outbox), original_outbox_length + 1)