Applied pylint-amnesty to commerce

This commit is contained in:
Jawayria
2021-02-01 18:56:15 +05:00
parent a5f6f682ee
commit 4b4fc89693
17 changed files with 28 additions and 28 deletions

View File

@@ -69,7 +69,7 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase)
self.assertEqual(actual, expected_msg)
def setUp(self):
super(BasketsViewTests, self).setUp()
super(BasketsViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.url = reverse('commerce_api:v0:baskets:create')
self._login()
@@ -290,7 +290,7 @@ class BasketOrderViewTests(UserMixin, TestCase):
path = reverse_lazy(view_name, kwargs={'basket_id': 1})
def setUp(self):
super(BasketOrderViewTests, self).setUp()
super(BasketOrderViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self._login()
def test_order_found(self):

View File

@@ -88,7 +88,7 @@ class BasketsView(APIView):
u'Failed to handle marketing opt-in flag: user="%s", course="%s"', user.username, course_key
)
def post(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument
"""
Attempt to enroll the user.
"""

View File

@@ -130,7 +130,7 @@ class Course(object):
course_id = CourseKey.from_string(six.text_type(course_id))
except InvalidKeyError:
log.debug(u'[%s] is not a valid course key.', course_id)
raise ValueError
raise ValueError # lint-amnesty, pylint: disable=raise-missing-from
course_modes = CourseMode.objects.filter(course_id=course_id)

View File

@@ -1,7 +1,7 @@
""" Custom API permissions. """
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from rest_framework.permissions import BasePermission, DjangoModelPermissions
from openedx.core.lib.api.permissions import ApiKeyHeaderPermission
@@ -22,7 +22,7 @@ class IsAuthenticatedOrActivationOverridden(BasePermission):
def has_permission(self, request, view):
if not request.user.is_authenticated and is_account_activation_requirement_disabled():
try:
request.user = User.objects.get(id=request.session._session_cache['_auth_user_id'])
request.user = User.objects.get(id=request.session._session_cache['_auth_user_id']) # lint-amnesty, pylint: disable=protected-access
except User.DoesNotExist:
pass
return request.user.is_authenticated

View File

@@ -47,7 +47,7 @@ def validate_course_id(course_id):
try:
course_key = CourseKey.from_string(six.text_type(course_id))
except InvalidKeyError:
raise serializers.ValidationError(
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from
_(u"{course_id} is not a valid course key.").format(
course_id=course_id
)
@@ -69,7 +69,7 @@ class PossiblyUndefinedDateTimeField(serializers.DateTimeField):
def to_representation(self, value):
if value is UNDEFINED:
return None
return super(PossiblyUndefinedDateTimeField, self).to_representation(value)
return super(PossiblyUndefinedDateTimeField, self).to_representation(value) # lint-amnesty, pylint: disable=super-with-arguments
class CourseSerializer(serializers.Serializer):

View File

@@ -14,7 +14,7 @@ class CourseTests(TestCase):
""" Tests for Course model. """
def setUp(self):
super(CourseTests, self).setUp()
super(CourseTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = Course('a/b/c', [])
@ddt.unpack

View File

@@ -35,7 +35,7 @@ class CourseApiViewTestMixin(object):
"""
def setUp(self):
super(CourseApiViewTestMixin, self).setUp()
super(CourseApiViewTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
self.course_mode = CourseMode.objects.create(
course_id=self.course.id,
@@ -114,7 +114,7 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase)
}
def setUp(self):
super(CourseRetrieveUpdateViewTests, self).setUp()
super(CourseRetrieveUpdateViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.path = reverse('commerce_api:v1:courses:retrieve_update', args=[six.text_type(self.course.id)])
self.user = UserFactory.create()
self.client.login(username=self.user.username, password=PASSWORD)
@@ -450,7 +450,7 @@ class OrderViewTests(UserMixin, TestCase):
path = reverse_lazy(view_name, kwargs={'number': ORDER_NUMBER})
def setUp(self):
super(OrderViewTests, self).setUp()
super(OrderViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self._login()
def test_order_found(self):

View File

@@ -5,7 +5,7 @@ Commerce views
import logging
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.http import Http404
from edx_rest_api_client import exceptions
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
@@ -53,7 +53,7 @@ class CourseRetrieveUpdateView(PutAsCreateMixin, RetrieveUpdateAPIView):
# rather than a CourseMode, so this isn't really used.
queryset = CourseMode.objects.all()
def get_object(self, queryset=None):
def get_object(self, queryset=None): # lint-amnesty, pylint: disable=arguments-differ, unused-argument
course_id = self.kwargs.get(self.lookup_url_kwarg)
course = Course.get(course_id)
@@ -80,7 +80,7 @@ class OrderView(APIView):
# anonymous user object attached to the request with the actual user object (if it exists)
if not request.user.is_authenticated and is_account_activation_requirement_disabled():
try:
request.user = User.objects.get(id=request.session._session_cache['_auth_user_id'])
request.user = User.objects.get(id=request.session._session_cache['_auth_user_id']) # lint-amnesty, pylint: disable=protected-access
except User.DoesNotExist:
return JsonResponse(status=403)
try:

View File

@@ -3,4 +3,4 @@
class InvalidResponseError(Exception):
""" Exception raised when an API response is invalid. """
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass

View File

@@ -11,7 +11,7 @@ class DetailResponse(JsonResponse):
def __init__(self, message, status=HTTP_200_OK):
data = {'detail': message}
super(DetailResponse, self).__init__(resp_obj=data, status=status)
super(DetailResponse, self).__init__(resp_obj=data, status=status) # lint-amnesty, pylint: disable=super-with-arguments
class InternalRequestErrorResponse(DetailResponse):
@@ -22,4 +22,4 @@ class InternalRequestErrorResponse(DetailResponse):
u'Call to E-Commerce API failed. Internal Service Message: [{internal_message}]'
.format(internal_message=internal_message)
)
super(InternalRequestErrorResponse, self).__init__(message=message, status=HTTP_500_INTERNAL_SERVER_ERROR)
super(InternalRequestErrorResponse, self).__init__(message=message, status=HTTP_500_INTERNAL_SERVER_ERROR) # lint-amnesty, pylint: disable=super-with-arguments

View File

@@ -289,4 +289,4 @@ class Command(BaseCommand):
except Exception as ex:
traceback.print_exc()
raise CommandError(u'Command failed with traceback %s' % str(ex))
raise CommandError(u'Command failed with traceback %s' % str(ex)) # lint-amnesty, pylint: disable=raise-missing-from

View File

@@ -34,7 +34,7 @@ class EdxRestApiClientTest(TestCase):
]
def setUp(self):
super(EdxRestApiClientTest, self).setUp()
super(EdxRestApiClientTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory()
@httpretty.activate

View File

@@ -95,7 +95,7 @@ class mock_basket_order(mock_ecommerce_api_endpoint):
method = httpretty.GET
def __init__(self, basket_id, **kwargs):
super(mock_basket_order, self).__init__(**kwargs)
super(mock_basket_order, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
self.basket_id = basket_id
def get_path(self):
@@ -131,7 +131,7 @@ class mock_process_refund(mock_ecommerce_api_endpoint):
method = httpretty.PUT
def __init__(self, refund_id, **kwargs):
super(mock_process_refund, self).__init__(**kwargs)
super(mock_process_refund, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
self.refund_id = refund_id
def get_path(self):
@@ -145,7 +145,7 @@ class mock_order_endpoint(mock_ecommerce_api_endpoint):
method = httpretty.GET
def __init__(self, order_number, **kwargs):
super(mock_order_endpoint, self).__init__(**kwargs)
super(mock_order_endpoint, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
self.order_number = order_number
def get_path(self):

View File

@@ -40,7 +40,7 @@ class TestRefundSignal(TestCase):
"""
def setUp(self):
super(TestRefundSignal, self).setUp()
super(TestRefundSignal, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# Ensure the E-Commerce service user exists
UserFactory(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME, is_staff=True)

View File

@@ -61,7 +61,7 @@ class EcommerceServiceTests(TestCase):
self.user = UserFactory.create()
self.request = self.request_factory.get("foo")
update_commerce_config(enabled=True)
super(EcommerceServiceTests, self).setUp()
super(EcommerceServiceTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
def test_is_enabled(self):
"""Verify that is_enabled() returns True when ecomm checkout is enabled. """
@@ -187,7 +187,7 @@ class RefundUtilMethodTests(ModuleStoreTestCase):
"""Tests for Refund Utilities"""
def setUp(self):
super(RefundUtilMethodTests, self).setUp()
super(RefundUtilMethodTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory()
UserFactory(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME, is_staff=True)

View File

@@ -7,7 +7,7 @@ class UserMixin(object):
""" Mixin for tests involving users. """
def setUp(self):
super(UserMixin, self).setUp()
super(UserMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory()
def _login(self):

View File

@@ -18,7 +18,7 @@ from common.djangoapps.course_modes.models import CourseMode
from openedx.core.djangoapps.commerce.utils import ecommerce_api_client, is_commerce_service_configured
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.theming import helpers as theming_helpers
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.models import CourseEnrollment # lint-amnesty, pylint: disable=unused-import
from .models import CommerceConfiguration