Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
test: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
julianajlk committed Apr 8, 2024
1 parent 8d36e70 commit d652075
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ecommerce/extensions/payment/tests/processors/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def setUp(self):
"currency": "usd",
"description": "EDX-100001",
"metadata": {
"courses": "[{'course_id': 'course-v1:edX+DemoX+Demo_Course', 'course_name': 'edX Demonstration Course'}]",
"order_number": "EDX-100001"
},
"payment_intent": "pi_3OzUOMH4caH7G0X114tkIL0X",
Expand All @@ -74,7 +73,6 @@ def setUp(self):
},
"type": "afterpay_clearpay"
},
"receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xTHM3UVNINGNhSDdHMFgxKOy4mLAGMgYXtd9MJi06LBZw14jVkz0vKozsqk2_q6lLrskTm5gm4anP-pVGppcQYWwfthMZIPXhKyn5",
"shipping": {
"address": {
"city": "Beverly Hills",
Expand All @@ -97,10 +95,6 @@ def setUp(self):
"currency": "usd",
"description": "EDX-100001",
"latest_charge": "py_3OzUOMH4caH7G0X11OOKbfIk",
"metadata": {
"courses": "[{'course_id': 'course-v1:edX+DemoX+Demo_Course', 'course_name': 'edX Demonstration Course'}]",
"order_number": "EDX-100001"
},
"payment_method": "pm_1OzURzH4caH7G0X19vH5rGBT",
"payment_method_configuration_details": {
"id": "pmc_1LspDWH4caH7G0X1LXrN8QMJ",
Expand Down Expand Up @@ -179,7 +173,8 @@ def test_handle_webhooks_payment(self):
"""
with mock.patch('ecommerce.extensions.analytics.utils.track_segment_event') as mock_track:
with mock.patch('stripe.PaymentIntent.retrieve') as mock_retrieve:
with mock.patch('ecommerce.extensions.checkout.mixins.EdxOrderPlacementMixin.handle_post_order') as mock_post_order:
with mock.patch(
'ecommerce.extensions.checkout.mixins.EdxOrderPlacementMixin.handle_post_order') as mock_post_order:
mock_retrieve.return_value = {
'id': self.payment_intent['id'],
'client_secret': self.payment_intent['client_secret'],
Expand All @@ -190,7 +185,9 @@ def test_handle_webhooks_payment(self):
'type': self.payment_intent['charges']['data'][0]['payment_method_details']['type']
},
}
self.processor_class(self.site).handle_webhooks_payment(RequestFactory(), self.payment_intent, 'afterpay_clearpay')
self.processor_class(self.site).handle_webhooks_payment(
RequestFactory(), self.payment_intent, 'afterpay_clearpay'
)
properties = {
'basket_id': self.basket.id,
'processor_name': 'stripe',
Expand All @@ -199,4 +196,6 @@ def test_handle_webhooks_payment(self):
'success': True,
}
mock_post_order.assert_called_once()
mock_track.assert_called_once_with(self.basket.site, self.basket.owner, 'Payment Processor Response', properties)
mock_track.assert_called_once_with(
self.basket.site, self.basket.owner, 'Payment Processor Response', properties
)

0 comments on commit d652075

Please sign in to comment.