Esempio n. 1
0
    def test___str__(
        self,
        product_retrieve_mock,
        payment_intent_retrieve_mock,
        paymentmethod_card_retrieve_mock,
        charge_retrieve_mock,
        subscription_retrieve_mock,
        balance_transaction_retrieve_mock,
        default_account_mock,
    ):
        default_account_mock.return_value = self.account
        # TODO - remove invoice sync
        Invoice.sync_from_stripe_data(deepcopy(FAKE_INVOICE))

        fake_refund = deepcopy(FAKE_REFUND)
        fake_refund["reason"] = enums.RefundReason.requested_by_customer

        balance_transaction_retrieve_mock.return_value = deepcopy(
            FAKE_BALANCE_TRANSACTION_REFUND)

        refund = Refund.sync_from_stripe_data(fake_refund)

        self.assertEqual(str(refund), "$20.00 USD (Succeeded)")

        self.assert_fks(refund,
                        expected_blank_fks=self.default_expected_blank_fks)
Esempio n. 2
0
    def test_sync_from_stripe_data(
        self,
        product_retrieve_mock,
        payment_intent_retrieve_mock,
        paymentmethod_card_retrieve_mock,
        charge_retrieve_mock,
        subscription_retrieve_mock,
        balance_transaction_retrieve_mock,
        default_account_mock,
    ):
        default_account_mock.return_value = self.account
        # TODO - remove invoice sync
        Invoice.sync_from_stripe_data(deepcopy(FAKE_INVOICE))

        fake_refund = deepcopy(FAKE_REFUND)

        balance_transaction_retrieve_mock.return_value = deepcopy(
            FAKE_BALANCE_TRANSACTION_REFUND
        )

        refund = Refund.sync_from_stripe_data(fake_refund)

        self.assert_fks(refund, expected_blank_fks=self.default_expected_blank_fks)
Esempio n. 3
0
    def test_status_enum(
        self,
        product_retrieve_mock,
        payment_intent_retrieve_mock,
        paymentmethod_card_retrieve_mock,
        charge_retrieve_mock,
        subscription_retrieve_mock,
        balance_transaction_retrieve_mock,
        default_account_mock,
    ):
        default_account_mock.return_value = self.account
        # TODO - remove invoice sync
        Invoice.sync_from_stripe_data(deepcopy(FAKE_INVOICE))

        balance_transaction_retrieve_mock.return_value = deepcopy(
            FAKE_BALANCE_TRANSACTION_REFUND
        )

        fake_refund = deepcopy(FAKE_REFUND)

        for status in (
            "pending",
            "succeeded",
            "failed",
            "canceled",
        ):
            fake_refund["status"] = status

            refund = Refund.sync_from_stripe_data(fake_refund)

            self.assertEqual(refund.status, status)

            # trigger model field validation (including enum value choices check)
            refund.full_clean()

            self.assert_fks(refund, expected_blank_fks=self.default_expected_blank_fks)
Esempio n. 4
0
    def test_reason_enum(
        self,
        product_retrieve_mock,
        payment_intent_retrieve_mock,
        paymentmethod_card_retrieve_mock,
        charge_retrieve_mock,
        subscription_retrieve_mock,
        balance_transaction_retrieve_mock,
        default_account_mock,
    ):
        default_account_mock.return_value = self.account
        # TODO - remove invoice sync
        Invoice.sync_from_stripe_data(deepcopy(FAKE_INVOICE))

        balance_transaction_retrieve_mock.return_value = deepcopy(
            FAKE_BALANCE_TRANSACTION_REFUND
        )

        fake_refund = deepcopy(FAKE_REFUND)

        for reason in (
            "duplicate",
            "fraudulent",
            "requested_by_customer",
            "expired_uncaptured_charge",
        ):
            fake_refund["reason"] = reason

            refund = Refund.sync_from_stripe_data(fake_refund)

            self.assertEqual(refund.reason, reason)

            # trigger model field validation (including enum value choices check)
            refund.full_clean()

            self.assert_fks(refund, expected_blank_fks=self.default_expected_blank_fks)