Merge pull request #26295 from edx/BOM-2283

BOM-2283
This commit is contained in:
Usama Sadiq
2021-02-02 16:40:42 +05:00
committed by GitHub
18 changed files with 55 additions and 54 deletions

View File

@@ -1,3 +1,4 @@
""" """
# lint-amnesty, pylint: disable=django-not-configured
Initialization app for the LMS Initialization app for the LMS
""" """

View File

@@ -24,7 +24,7 @@ class LmsFieldData(SplitFieldData):
self._authored_data = authored_data self._authored_data = authored_data
self._student_data = student_data self._student_data = student_data
super(LmsFieldData, self).__init__({ super(LmsFieldData, self).__init__({ # lint-amnesty, pylint: disable=super-with-arguments
Scope.content: authored_data, Scope.content: authored_data,
Scope.settings: authored_data, Scope.settings: authored_data,
Scope.parent: authored_data, Scope.parent: authored_data,

View File

@@ -198,7 +198,7 @@ class LmsBlockMixin(XBlockMixin):
Validates the state of this xblock instance. Validates the state of this xblock instance.
""" """
_ = self.runtime.service(self, "i18n").ugettext _ = self.runtime.service(self, "i18n").ugettext
validation = super(LmsBlockMixin, self).validate() validation = super(LmsBlockMixin, self).validate() # lint-amnesty, pylint: disable=super-with-arguments
has_invalid_user_partitions = False has_invalid_user_partitions = False
has_invalid_groups = False has_invalid_groups = False
block_is_unit = is_unit(self) block_is_unit = is_unit(self)
@@ -253,7 +253,7 @@ class LmsBlockMixin(XBlockMixin):
Publish completion data from the front end. Publish completion data from the front end.
""" """
completion_service = self.runtime.service(self, 'completion') completion_service = self.runtime.service(self, 'completion')
if completion_service is None: if completion_service is None: # lint-amnesty, pylint: disable=no-else-raise
raise JsonHandlerError(500, u"No completion service found") raise JsonHandlerError(500, u"No completion service found")
elif not completion_service.completion_tracking_enabled(): elif not completion_service.completion_tracking_enabled():
raise JsonHandlerError(404, u"Completion tracking is not enabled and API calls are unexpected") raise JsonHandlerError(404, u"Completion tracking is not enabled and API calls are unexpected")

View File

@@ -166,9 +166,9 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method
services['teams'] = TeamsService() services['teams'] = TeamsService()
services['teams_configuration'] = TeamsConfigurationService() services['teams_configuration'] = TeamsConfigurationService()
services['call_to_action'] = CallToActionService() services['call_to_action'] = CallToActionService()
super(LmsModuleSystem, self).__init__(**kwargs) super(LmsModuleSystem, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
def handler_url(self, *args, **kwargs): def handler_url(self, *args, **kwargs): # lint-amnesty, pylint: disable=signature-differs
""" """
Implement the XBlock runtime handler_url interface. Implement the XBlock runtime handler_url interface.
@@ -244,6 +244,6 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method
# (see https://openedx.atlassian.net/browse/TE-811) # (see https://openedx.atlassian.net/browse/TE-811)
return [ return [
aside_type aside_type
for aside_type in super(LmsModuleSystem, self).applicable_aside_types(block) for aside_type in super(LmsModuleSystem, self).applicable_aside_types(block) # lint-amnesty, pylint: disable=super-with-arguments
if aside_type != 'acid_aside' if aside_type != 'acid_aside'
] ]

View File

@@ -29,19 +29,19 @@ class BlockMock(Mock):
""" """
A test handler method. A test handler method.
""" """
pass pass # lint-amnesty, pylint: disable=unnecessary-pass
def handler1(self, _context): def handler1(self, _context):
""" """
A test handler method. A test handler method.
""" """
pass pass # lint-amnesty, pylint: disable=unnecessary-pass
def handler_a(self, _context): def handler_a(self, _context):
""" """
A test handler method. A test handler method.
""" """
pass pass # lint-amnesty, pylint: disable=unnecessary-pass
@property @property
def location(self): def location(self):
@@ -54,7 +54,7 @@ class TestHandlerUrl(TestCase):
"""Test the LMS handler_url""" """Test the LMS handler_url"""
def setUp(self): def setUp(self):
super(TestHandlerUrl, self).setUp() super(TestHandlerUrl, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.block = BlockMock(name='block', scope_ids=ScopeIds(None, None, None, 'dummy')) self.block = BlockMock(name='block', scope_ids=ScopeIds(None, None, None, 'dummy'))
self.course_key = CourseLocator("org", "course", "run") self.course_key = CourseLocator("org", "course", "run")
self.runtime = LmsModuleSystem( self.runtime = LmsModuleSystem(
@@ -119,7 +119,7 @@ class TestUserServiceAPI(TestCase):
"""Test the user service interface""" """Test the user service interface"""
def setUp(self): def setUp(self):
super(TestUserServiceAPI, self).setUp() super(TestUserServiceAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_id = CourseLocator("org", "course", "run") self.course_id = CourseLocator("org", "course", "run")
self.user = UserFactory.create() self.user = UserFactory.create()
@@ -169,7 +169,7 @@ class TestBadgingService(ModuleStoreTestCase):
"""Test the badging service interface""" """Test the badging service interface"""
def setUp(self): def setUp(self):
super(TestBadgingService, self).setUp() super(TestBadgingService, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_id = CourseKey.from_string('course-v1:org+course+run') self.course_id = CourseKey.from_string('course-v1:org+course+run')
self.mock_block = Mock() self.mock_block = Mock()
@@ -235,7 +235,7 @@ class TestI18nService(ModuleStoreTestCase):
def setUp(self): def setUp(self):
""" Setting up tests """ """ Setting up tests """
super(TestI18nService, self).setUp() super(TestI18nService, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.test_language = 'dummy language' self.test_language = 'dummy language'
self.runtime = LmsModuleSystem( self.runtime = LmsModuleSystem(

View File

@@ -1,4 +1,4 @@
""" """ # lint-amnesty, pylint: disable=django-not-configured
The LTI Provider app gives a way to launch edX content via a campus LMS The LTI Provider app gives a way to launch edX content via a campus LMS
platform. LTI is a standard protocol for connecting educational tools, defined platform. LTI is a standard protocol for connecting educational tools, defined
by IMS: by IMS:

View File

@@ -64,7 +64,7 @@ class CommandExecutionTestCase(SharedModuleStoreTestCase):
cls.lti_block = u'block-v1:edX+lti_provider+3000+type@chapter+block@chapter_2' cls.lti_block = u'block-v1:edX+lti_provider+3000+type@chapter+block@chapter_2'
def setUp(self): def setUp(self):
super(CommandExecutionTestCase, self).setUp() super(CommandExecutionTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory() self.user = UserFactory()
self.user2 = UserFactory(username=u'anotheruser') self.user2 = UserFactory(username=u'anotheruser')
self.client.login(username=self.user.username, password=u'test') self.client.login(username=self.user.username, password=u'test')

View File

@@ -12,7 +12,7 @@ changes. To do that,
import logging 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.db import models from django.db import models
from opaque_keys.edx.django.models import CourseKeyField, UsageKeyField from opaque_keys.edx.django.models import CourseKeyField, UsageKeyField

View File

@@ -71,23 +71,23 @@ def generate_replace_result_xml(result_sourcedid, score):
""" """
# Pylint doesn't recognize members in the LXML module # Pylint doesn't recognize members in the LXML module
elem = ElementMaker(nsmap={None: 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'}) elem = ElementMaker(nsmap={None: 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'})
xml = elem.imsx_POXEnvelopeRequest( xml = elem.imsx_POXEnvelopeRequest( # lint-amnesty, pylint: disable=no-member
elem.imsx_POXHeader( elem.imsx_POXHeader( # lint-amnesty, pylint: disable=no-member
elem.imsx_POXRequestHeaderInfo( elem.imsx_POXRequestHeaderInfo( # lint-amnesty, pylint: disable=no-member
elem.imsx_version('V1.0'), elem.imsx_version('V1.0'), # lint-amnesty, pylint: disable=no-member
elem.imsx_messageIdentifier(str(uuid.uuid4())) elem.imsx_messageIdentifier(str(uuid.uuid4())) # lint-amnesty, pylint: disable=no-member
) )
), ),
elem.imsx_POXBody( elem.imsx_POXBody( # lint-amnesty, pylint: disable=no-member
elem.replaceResultRequest( elem.replaceResultRequest( # lint-amnesty, pylint: disable=no-member
elem.resultRecord( elem.resultRecord( # lint-amnesty, pylint: disable=no-member
elem.sourcedGUID( elem.sourcedGUID( # lint-amnesty, pylint: disable=no-member
elem.sourcedId(result_sourcedid) elem.sourcedId(result_sourcedid) # lint-amnesty, pylint: disable=no-member
), ),
elem.result( elem.result( # lint-amnesty, pylint: disable=no-member
elem.resultScore( elem.resultScore( # lint-amnesty, pylint: disable=no-member
elem.language('en'), elem.language('en'), # lint-amnesty, pylint: disable=no-member
elem.textString(str(score)) elem.textString(str(score)) # lint-amnesty, pylint: disable=no-member
) )
) )
) )

View File

@@ -18,7 +18,7 @@ class SignatureValidator(RequestValidator):
""" """
def __init__(self, lti_consumer): def __init__(self, lti_consumer):
super(SignatureValidator, self).__init__() super(SignatureValidator, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments
self.endpoint = SignatureOnlyEndpoint(self) self.endpoint = SignatureOnlyEndpoint(self)
self.lti_consumer = lti_consumer self.lti_consumer = lti_consumer
@@ -31,7 +31,7 @@ class SignatureValidator(RequestValidator):
# on the platform. # on the platform.
enforce_ssl = False enforce_ssl = False
def check_client_key(self, key): def check_client_key(self, key): # lint-amnesty, pylint: disable=arguments-differ
""" """
Verify that the key supplied by the LTI consumer is valid for an LTI Verify that the key supplied by the LTI consumer is valid for an LTI
launch. This method is only concerned with the structure of the key; launch. This method is only concerned with the structure of the key;
@@ -141,13 +141,13 @@ class SignatureValidator(RequestValidator):
""" """
raise NotImplementedError raise NotImplementedError
def dummy_access_token(self): def dummy_access_token(self): # lint-amnesty, pylint: disable=invalid-overridden-method
""" """
Unused abstract method from super class. See documentation in RequestValidator Unused abstract method from super class. See documentation in RequestValidator
""" """
raise NotImplementedError raise NotImplementedError
def dummy_client(self): def dummy_client(self): # lint-amnesty, pylint: disable=invalid-overridden-method
""" """
Unused abstract method from super class. See documentation in RequestValidator Unused abstract method from super class. See documentation in RequestValidator
""" """
@@ -172,7 +172,7 @@ class SignatureValidator(RequestValidator):
""" """
raise NotImplementedError raise NotImplementedError
def dummy_request_token(self): def dummy_request_token(self): # lint-amnesty, pylint: disable=invalid-overridden-method
""" """
Unused abstract method from super class. See documentation in RequestValidator Unused abstract method from super class. See documentation in RequestValidator
""" """

View File

@@ -5,7 +5,7 @@ Asynchronous tasks for the LTI provider app.
import logging import logging
from django.contrib.auth.models import User from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
import lms.djangoapps.lti_provider.outcomes as outcomes import lms.djangoapps.lti_provider.outcomes as outcomes

View File

@@ -21,7 +21,7 @@ class StoreOutcomeParametersTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(StoreOutcomeParametersTest, self).setUp() super(StoreOutcomeParametersTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create() self.user = UserFactory.create()
self.course_key = CourseLocator( self.course_key = CourseLocator(
org='some_org', org='some_org',
@@ -135,7 +135,7 @@ class SignAndSendReplaceResultTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(SignAndSendReplaceResultTest, self).setUp() super(SignAndSendReplaceResultTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_key = CourseLocator( self.course_key = CourseLocator(
org='some_org', org='some_org',
course='some_course', course='some_course',
@@ -298,7 +298,7 @@ class TestAssignmentsForProblem(ModuleStoreTestCase):
""" """
def setUp(self): def setUp(self):
super(TestAssignmentsForProblem, self).setUp() super(TestAssignmentsForProblem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create() self.user = UserFactory.create()
self.user_id = self.user.id self.user_id = self.user.id
self.outcome_service = self.create_outcome_service('outcomes') self.outcome_service = self.create_outcome_service('outcomes')

View File

@@ -30,7 +30,7 @@ class ClientKeyValidatorTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(ClientKeyValidatorTest, self).setUp() super(ClientKeyValidatorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.lti_consumer = get_lti_consumer() self.lti_consumer = get_lti_consumer()
def test_valid_client_key(self): def test_valid_client_key(self):
@@ -60,7 +60,7 @@ class NonceValidatorTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(NonceValidatorTest, self).setUp() super(NonceValidatorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.lti_consumer = get_lti_consumer() self.lti_consumer = get_lti_consumer()
def test_valid_nonce(self): def test_valid_nonce(self):
@@ -91,7 +91,7 @@ class SignatureValidatorTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(SignatureValidatorTest, self).setUp() super(SignatureValidatorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.lti_consumer = get_lti_consumer() self.lti_consumer = get_lti_consumer()
def test_get_existing_client_secret(self): def test_get_existing_client_secret(self):

View File

@@ -19,7 +19,7 @@ class BaseOutcomeTest(TestCase):
Super type for tests of both the leaf and composite outcome celery tasks. Super type for tests of both the leaf and composite outcome celery tasks.
""" """
def setUp(self): def setUp(self):
super(BaseOutcomeTest, self).setUp() super(BaseOutcomeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_key = CourseLocator( self.course_key = CourseLocator(
org='some_org', org='some_org',
course='some_course', course='some_course',
@@ -96,7 +96,7 @@ class SendCompositeOutcomeTest(BaseOutcomeTest):
""" """
def setUp(self): def setUp(self):
super(SendCompositeOutcomeTest, self).setUp() super(SendCompositeOutcomeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.descriptor = MagicMock() self.descriptor = MagicMock()
self.descriptor.location = BlockUsageLocator( self.descriptor.location = BlockUsageLocator(
course_key=self.course_key, course_key=self.course_key,

View File

@@ -5,7 +5,7 @@ Tests for the LTI user management functionality
import string import string
from django.contrib.auth.models import User from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.test import TestCase from django.test import TestCase
from django.test.client import RequestFactory from django.test.client import RequestFactory
@@ -14,7 +14,7 @@ from six.moves import range
from .. import users from .. import users
from ..models import LtiConsumer, LtiUser from ..models import LtiConsumer, LtiUser
from common.djangoapps.student.tests.factories import UserFactory from common.djangoapps.student.tests.factories import UserFactory # lint-amnesty, pylint: disable=wrong-import-order
class UserManagementHelperTest(TestCase): class UserManagementHelperTest(TestCase):
@@ -23,7 +23,7 @@ class UserManagementHelperTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(UserManagementHelperTest, self).setUp() super(UserManagementHelperTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.request = RequestFactory().post('/') self.request = RequestFactory().post('/')
self.old_user = UserFactory.create() self.old_user = UserFactory.create()
self.new_user = UserFactory.create() self.new_user = UserFactory.create()
@@ -66,7 +66,7 @@ class UserManagementHelperTest(TestCase):
username = users.generate_random_edx_username() username = users.generate_random_edx_username()
self.assertLessEqual(len(username), 30, 'Username too long') self.assertLessEqual(len(username), 30, 'Username too long')
# Check that the username contains only allowable characters # Check that the username contains only allowable characters
for char in range(len(username)): for char in range(len(username)): # lint-amnesty, pylint: disable=consider-using-enumerate
self.assertIn( self.assertIn(
username[char], string.ascii_letters + string.digits, username[char], string.ascii_letters + string.digits,
u"Username has forbidden character '{}'".format(username[char]) u"Username has forbidden character '{}'".format(username[char])
@@ -81,7 +81,7 @@ class AuthenticateLtiUserTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(AuthenticateLtiUserTest, self).setUp() super(AuthenticateLtiUserTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.lti_consumer = LtiConsumer( self.lti_consumer = LtiConsumer(
consumer_name='TestConsumer', consumer_name='TestConsumer',
consumer_key='TestKey', consumer_key='TestKey',
@@ -148,7 +148,7 @@ class CreateLtiUserTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(CreateLtiUserTest, self).setUp() super(CreateLtiUserTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.lti_consumer = LtiConsumer( self.lti_consumer = LtiConsumer(
consumer_name='TestConsumer', consumer_name='TestConsumer',
consumer_key='TestKey', consumer_key='TestKey',
@@ -185,7 +185,7 @@ class LtiBackendTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(LtiBackendTest, self).setUp() super(LtiBackendTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.edx_user = UserFactory.create() self.edx_user = UserFactory.create()
self.edx_user.save() self.edx_user.save()
self.lti_consumer = LtiConsumer( self.lti_consumer = LtiConsumer(

View File

@@ -68,7 +68,7 @@ class LtiTestMixin(object):
""" """
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_LTI_PROVIDER': True}) @patch.dict('django.conf.settings.FEATURES', {'ENABLE_LTI_PROVIDER': True})
def setUp(self): def setUp(self):
super(LtiTestMixin, self).setUp() super(LtiTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# Always accept the OAuth signature # Always accept the OAuth signature
self.mock_verify = MagicMock(return_value=True) self.mock_verify = MagicMock(return_value=True)
patcher = patch('lms.djangoapps.lti_provider.signature_validator.SignatureValidator.verify', self.mock_verify) patcher = patch('lms.djangoapps.lti_provider.signature_validator.SignatureValidator.verify', self.mock_verify)

View File

@@ -10,7 +10,7 @@ import uuid
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate, login from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from six.moves import range from six.moves import range

View File

@@ -83,7 +83,7 @@ def lti_launch(request, course_id, usage_id):
usage_id, usage_id,
request request
) )
raise Http404() raise Http404() # lint-amnesty, pylint: disable=raise-missing-from
params['course_key'] = course_key params['course_key'] = course_key
params['usage_key'] = usage_key params['usage_key'] = usage_key