From 1e10a5282d2bbad4265f1a0be783612c99b0b7b4 Mon Sep 17 00:00:00 2001 From: Samar Hassan <88422175+samar-hassan@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:26:05 +0000 Subject: [PATCH] [Fix] Resolve lint errors (#328) * fix :wrench: resolve lint errors * fix :wrench: resolve pylint errors * fix :wrench: resolve tests failing --- .gitignore | 3 ++- oscarapi/fixtures/offer.xml | 1 + oscarapi/fixtures/voucher.xml | 1 + oscarapi/middleware.py | 2 +- oscarapi/settings.py | 1 + oscarapi/signals.py | 8 +------- oscarapi/tests/unit/testmiddleware.py | 2 +- oscarapi/tests/unit/testproduct.py | 9 ++++++--- oscarapi/utils/exists.py | 1 + 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index e904498a..a567e1a7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ version-django-oscar-commerce-connect.txt sandbox/media/ sandbox/static/ docs/build/ -lint.installed \ No newline at end of file +lint.installed +.vscode diff --git a/oscarapi/fixtures/offer.xml b/oscarapi/fixtures/offer.xml index c69eeed3..4c455240 100644 --- a/oscarapi/fixtures/offer.xml +++ b/oscarapi/fixtures/offer.xml @@ -27,6 +27,7 @@ 0 0 + False 2015-11-16T11:08:15.653721+00:00 diff --git a/oscarapi/fixtures/voucher.xml b/oscarapi/fixtures/voucher.xml index 34919a29..537f213d 100644 --- a/oscarapi/fixtures/voucher.xml +++ b/oscarapi/fixtures/voucher.xml @@ -19,6 +19,7 @@ 0 0 + False 2015-11-27T15:38:48.134807+00:00 diff --git a/oscarapi/middleware.py b/oscarapi/middleware.py index 2f27439d..933a2691 100644 --- a/oscarapi/middleware.py +++ b/oscarapi/middleware.py @@ -5,7 +5,7 @@ from django.contrib.sessions.middleware import SessionMiddleware from django.core.exceptions import PermissionDenied from django.http.response import HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from oscar.core.loading import get_class diff --git a/oscarapi/settings.py b/oscarapi/settings.py index 542e11ba..67408e2a 100644 --- a/oscarapi/settings.py +++ b/oscarapi/settings.py @@ -5,6 +5,7 @@ `OSCARAPI_`. So :const:`oscarapi.settings.EXPOSE_USER_DETAILS` becomes: `OSCARAPI_EXPOSE_USER_DETAILS` """ + from django.contrib.auth import get_user_model from oscarapi.utils.settings import overridable from oscarapi import version diff --git a/oscarapi/signals.py b/oscarapi/signals.py index 17d20090..3b11f7fa 100644 --- a/oscarapi/signals.py +++ b/oscarapi/signals.py @@ -1,10 +1,4 @@ -import django from django.dispatch import Signal -oscarapi_post_checkout_args = ["order", "user", "request", "response"] - -if django.VERSION >= (3, 0): - oscarapi_post_checkout = Signal() -else: - oscarapi_post_checkout = Signal(providing_args=oscarapi_post_checkout_args) +oscarapi_post_checkout = Signal() diff --git a/oscarapi/tests/unit/testmiddleware.py b/oscarapi/tests/unit/testmiddleware.py index 24f5918d..e67e16be 100644 --- a/oscarapi/tests/unit/testmiddleware.py +++ b/oscarapi/tests/unit/testmiddleware.py @@ -105,7 +105,7 @@ def test_process_request(self): request = self.rf.get( basket_url, HTTP_SESSION_ID="SID:ANON:example.com:987171879" ) - response = HeaderSessionMiddleware().process_request(request) + response = HeaderSessionMiddleware(lambda: None).process_request(request) self.assertEqual(response.status_code, 403) self.assertEqual( response.content, diff --git a/oscarapi/tests/unit/testproduct.py b/oscarapi/tests/unit/testproduct.py index 8abedbf6..0767cba9 100644 --- a/oscarapi/tests/unit/testproduct.py +++ b/oscarapi/tests/unit/testproduct.py @@ -1173,8 +1173,9 @@ def test_add_local_image(self): "description": "Henk", "images": [ { - "original": "https://testserver/%s/image.jpg" - % settings.MEDIA_ROOT, + "original": ( + "https://testserver/%s/image.jpg" % settings.MEDIA_ROOT + ), "caption": "HA! IK HEET HARRIE", } ], @@ -1210,7 +1211,9 @@ def test_add_broken_image(self, urlopen): "description": "Henk", "images": [ { - "original": "https://example.com/image-that-does-not-exist-at-all.png", + "original": ( + "https://example.com/image-that-does-not-exist-at-all.png" + ), "caption": "HA! IK HEET HARRIE", } ], diff --git a/oscarapi/utils/exists.py b/oscarapi/utils/exists.py index c82d88fa..b81c7d31 100644 --- a/oscarapi/utils/exists.py +++ b/oscarapi/utils/exists.py @@ -2,6 +2,7 @@ This module contains functions that can be used to identify an existing piece of data in the database based on it's unique attributes """ + from django.db import models from oscar.core.loading import get_model