diff --git a/ecommerce/extensions/payment/tests/processors/test_webhooks.py b/ecommerce/extensions/payment/tests/processors/test_webhooks.py index cca1a2f369d..2d5a2e2c912 100644 --- a/ecommerce/extensions/payment/tests/processors/test_webhooks.py +++ b/ecommerce/extensions/payment/tests/processors/test_webhooks.py @@ -20,6 +20,7 @@ Applicator = get_class('offer.applicator', 'Applicator') BillingAddress = get_model('order', 'BillingAddress') Country = get_model('address', 'Country') +Order = get_model('order', 'Order') OrderNumberGenerator = get_class('order.utils', 'OrderNumberGenerator') @@ -145,10 +146,16 @@ def test_issue_credit_error(self): """ self.skipTest('Webhooks payments processor does not yet support issuing credit.') + @mock.patch('ecommerce.extensions.checkout.mixins.EdxOrderPlacementMixin.create_order') @mock.patch('ecommerce.extensions.checkout.mixins.EdxOrderPlacementMixin.handle_post_order') @mock.patch('stripe.PaymentIntent.retrieve') @mock.patch('ecommerce.extensions.payment.processors.webhooks.track_segment_event') - def test_handle_webhooks_payment(self, mock_track, mock_retrieve, mock_handle_post_order): + def test_handle_webhooks_payment( + self, + mock_track, + mock_retrieve, + mock_handle_post_order, + mock_create_order): """ Verify a payment received via Stripe webhooks is processed, an order is created and fulfilled. """ @@ -181,13 +188,13 @@ def test_handle_webhooks_payment(self, mock_track, mock_retrieve, mock_handle_po mock_track.assert_called_once_with( self.basket.site, self.basket.owner, 'Payment Processor Response', properties ) + mock_create_order.assert_called_once() mock_handle_post_order.assert_called_once() - @mock.patch('ecommerce.extensions.checkout.mixins.EdxOrderPlacementMixin.create_order') @mock.patch('ecommerce.extensions.checkout.mixins.EdxOrderPlacementMixin.handle_post_order') @mock.patch('stripe.PaymentIntent.retrieve') @mock.patch('ecommerce.extensions.payment.processors.webhooks.track_segment_event') - def test_handle_webhooks_payment_with_voucher(self, mock_track, mock_retrieve, mock_handle_post_order, mock_create_order): + def test_handle_webhooks_payment_with_voucher(self, mock_track, mock_retrieve, mock_handle_post_order): """ Verify a payment received via Stripe webhooks is processed, an order is created and fulfilled with a coupon. """ @@ -231,6 +238,7 @@ def test_handle_webhooks_payment_with_voucher(self, mock_track, mock_retrieve, m mock_track.assert_called_once_with( basket.site, basket.owner, 'Payment Processor Response', properties ) - mock_create_order.assert_called_once() mock_handle_post_order.assert_called_once() - assert basket.total_incl_tax != basket.total_excl_tax_excl_discounts + order = Order.objects.get(number=basket.order_number) + assert order.total_incl_tax == basket.total_incl_tax + assert basket.total_incl_tax != basket.total_incl_tax_excl_discounts