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

Commit

Permalink
fixup! fix more failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robrap committed Apr 13, 2023
1 parent 2cb9b63 commit 3d8f0dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ecommerce/extensions/api/v2/tests/views/test_refunds.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
from ecommerce.extensions.refund.tests.factories import RefundFactory, RefundLineFactory
from ecommerce.extensions.refund.tests.mixins import RefundTestMixin
from ecommerce.extensions.test.factories import create_order
from ecommerce.tests.mixins import JwtMixin, ThrottlingMixin
from ecommerce.tests.mixins import ThrottlingMixin
from ecommerce.tests.testcases import TestCase

Option = get_model('catalogue', 'Option')
Refund = get_model('refund', 'Refund')


class RefundCreateViewTests(RefundTestMixin, AccessTokenMixin, JwtMixin, TestCase):
class RefundCreateViewTests(RefundTestMixin, AccessTokenMixin, TestCase):
MODEL_LOGGER_NAME = 'ecommerce.core.models'
path = reverse('api:v2:refunds:create')

Expand Down Expand Up @@ -104,7 +104,7 @@ def test_jwt_authentication(self):
self.client.logout()

data = self._get_data(self.user.username, self.course_id)
auth_header = 'JWT ' + self.generate_token({'username': self.user.username})
auth_header = self.generate_jwt_token_header(self.user)

response = self.client.post(self.path, data, JSON_CONTENT_TYPE, HTTP_AUTHORIZATION=auth_header)
self.assert_ok_response(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DynamicPercentageDiscountBenefitTests(BenefitTestMixin, TestCase):

@override_flag(DYNAMIC_DISCOUNT_FLAG, active=True)
@patch('crum.get_current_request')
@patch('ecommerce.extensions.offer.dynamic_conditional_offer.jwt_decode_handler',
@patch('ecommerce.extensions.offer.dynamic_conditional_offer.configured_jwt_decode_handler',
side_effect=_mock_jwt_decode_handler)
@patch('ecommerce.enterprise.utils.get_decoded_jwt',
side_effect=_mock_get_decoded_jwt)
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_name(self):

@override_flag(DYNAMIC_DISCOUNT_FLAG, active=True)
@patch('crum.get_current_request')
@patch('ecommerce.extensions.offer.dynamic_conditional_offer.jwt_decode_handler',
@patch('ecommerce.extensions.offer.dynamic_conditional_offer.configured_jwt_decode_handler',
side_effect=_mock_jwt_decode_handler)
@ddt.data(
{'discount_applicable': True, 'discount_percent': 15},
Expand Down
7 changes: 5 additions & 2 deletions ecommerce/management/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ def test_invalid_action(self):
self.assert_first_message(response, messages.ERROR, 'invalid-action is not a valid action.')

def test_refund_basket_transactions(self):
with mock.patch('ecommerce.management.utils.refund_basket_transactions') as mock_refund:
success_count = 0
failed_count = 0
result = (success_count, failed_count)
with mock.patch('ecommerce.management.views.refund_basket_transactions', return_value=result) as mock_refund:
response = self.client.post(self.path, {'action': 'refund_basket_transactions', 'basket_ids': '1,2,3'})
assert mock_refund.called_once_with(self.site, [1, 2, 3])
mock_refund.assert_called_once_with(self.site, [1, 2, 3])

assert response.status_code == 200
expected = 'Finished refunding basket transactions. [0] transactions were successfully refunded. ' \
Expand Down

0 comments on commit 3d8f0dd

Please sign in to comment.