Skip to content

Commit

Permalink
fix: get_response issue for middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
mumarkhan999 committed Dec 21, 2023
1 parent 78d3735 commit 878576b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ecommerce/extensions/analytics/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TrackingMiddlewareTests(TestCase):

def setUp(self):
super(TrackingMiddlewareTests, self).setUp()
self.middleware = middleware.TrackingMiddleware()
self.middleware = middleware.TrackingMiddleware(get_response=lambda request: None)
self.request_factory = RequestFactory()
self.user = self.create_user()

Expand Down
33 changes: 18 additions & 15 deletions ecommerce/extensions/catalogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,27 @@ def is_executive_education_2u_product(self):
]

def save(self, *args, **kwargs):
super(Product, self).save(*args, **kwargs) # pylint: disable=bad-super-call
try:
if not isinstance(self.attr.note, str) and self.attr.note is not None:
super(Product, self).save(*args, **kwargs) # pylint: disable=bad-super-call
try:
if not isinstance(self.attr.note, str) and self.attr.note is not None:
log_message_and_raise_validation_error(
'Failed to create Product. Product note value must be of type string'
)
except AttributeError:
pass

try:
if self.attr.notify_email is not None:
validate_email(self.attr.notify_email)
except ValidationError:
log_message_and_raise_validation_error(
'Failed to create Product. Product note value must be of type string'
'Notification email must be a valid email address.'
)
except AttributeError:
pass

try:
if self.attr.notify_email is not None:
validate_email(self.attr.notify_email)
except ValidationError:
log_message_and_raise_validation_error(
'Notification email must be a valid email address.'
)
except AttributeError:
pass
except AttributeError:
pass
except Exception: # pylint: disable=broad-except
super(Product, self).delete() # pylint: disable=bad-super-call


@receiver(post_init, sender=Product)
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/extensions/partner/apps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


from oscar.apps.partner.apps import PartnerConfig as CorePartnerConfig
from oscar.apps.partner import apps


class PartnerConfig(CorePartnerConfig):
class PartnerConfig(apps.PartnerConfig):
name = 'ecommerce.extensions.partner'
2 changes: 1 addition & 1 deletion ecommerce/extensions/payment/core/tests/test_sdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def test_sdn_is_down_sdn_fallback_called(
If there is no hit, allow purchase.
"""
request = RequestFactory().post('/payment/cybersource/submit/')
middleware = SessionMiddleware()
middleware = SessionMiddleware(get_response=lambda request: None)
middleware.process_request(request)
request.session.save()
site_configuration = self.site.siteconfiguration
Expand Down

0 comments on commit 878576b

Please sign in to comment.