Applied pylint-amnesty
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
# pylint: disable=missing-module-docstring
|
||||
# lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring
|
||||
default_app_config = 'cms.djangoapps.api.apps.ApiConfig'
|
||||
|
||||
@@ -26,7 +26,7 @@ User = get_user_model()
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CourseAccessRoleSerializer(serializers.ModelSerializer):
|
||||
class CourseAccessRoleSerializer(serializers.ModelSerializer): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
user = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())
|
||||
|
||||
class Meta:
|
||||
@@ -34,21 +34,21 @@ class CourseAccessRoleSerializer(serializers.ModelSerializer):
|
||||
fields = ('user', 'role',)
|
||||
|
||||
|
||||
class CourseRunScheduleSerializer(serializers.Serializer):
|
||||
class CourseRunScheduleSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method
|
||||
start = serializers.DateTimeField()
|
||||
end = serializers.DateTimeField()
|
||||
enrollment_start = serializers.DateTimeField(allow_null=True, required=False)
|
||||
enrollment_end = serializers.DateTimeField(allow_null=True, required=False)
|
||||
|
||||
|
||||
class CourseRunTeamSerializer(serializers.Serializer):
|
||||
class CourseRunTeamSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
|
||||
def to_internal_value(self, data):
|
||||
"""Overriding this to support deserialization, for write operations."""
|
||||
for member in data:
|
||||
try:
|
||||
User.objects.get(username=member['user'])
|
||||
except User.DoesNotExist:
|
||||
raise serializers.ValidationError(
|
||||
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
_('Course team user does not exist')
|
||||
)
|
||||
|
||||
@@ -64,10 +64,10 @@ class CourseRunTeamSerializer(serializers.Serializer):
|
||||
return instance
|
||||
|
||||
|
||||
class CourseRunTeamSerializerMixin(serializers.Serializer):
|
||||
class CourseRunTeamSerializerMixin(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
|
||||
team = CourseRunTeamSerializer(required=False)
|
||||
|
||||
def update_team(self, instance, team):
|
||||
def update_team(self, instance, team): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
# Existing data should remain intact when performing a partial update.
|
||||
if not self.partial:
|
||||
CourseAccessRole.objects.filter(course_id=instance.id).delete()
|
||||
@@ -91,7 +91,7 @@ def image_is_jpeg_or_png(value):
|
||||
u'Only JPEG and PNG image types are supported. {} is not valid'.format(content_type))
|
||||
|
||||
|
||||
class CourseRunImageField(serializers.ImageField):
|
||||
class CourseRunImageField(serializers.ImageField): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
default_validators = [image_is_jpeg_or_png]
|
||||
|
||||
def get_attribute(self, instance):
|
||||
@@ -103,7 +103,7 @@ class CourseRunImageField(serializers.ImageField):
|
||||
return request.build_absolute_uri(value)
|
||||
|
||||
|
||||
class CourseRunPacingTypeField(serializers.ChoiceField):
|
||||
class CourseRunPacingTypeField(serializers.ChoiceField): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def to_representation(self, value):
|
||||
return 'self_paced' if value else 'instructor_paced'
|
||||
|
||||
@@ -111,7 +111,7 @@ class CourseRunPacingTypeField(serializers.ChoiceField):
|
||||
return data == 'self_paced'
|
||||
|
||||
|
||||
class CourseRunImageSerializer(serializers.Serializer):
|
||||
class CourseRunImageSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
|
||||
# We set an empty default to prevent the parent serializer from attempting
|
||||
# to save this value to the Course object.
|
||||
card_image = CourseRunImageField(source='course_image', default=empty)
|
||||
@@ -126,13 +126,13 @@ class CourseRunImageSerializer(serializers.Serializer):
|
||||
return instance
|
||||
|
||||
|
||||
class CourseRunSerializerCommonFieldsMixin(serializers.Serializer):
|
||||
class CourseRunSerializerCommonFieldsMixin(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method
|
||||
schedule = CourseRunScheduleSerializer(source='*', required=False)
|
||||
pacing_type = CourseRunPacingTypeField(source='self_paced', required=False,
|
||||
choices=((False, 'instructor_paced'), (True, 'self_paced'),))
|
||||
|
||||
|
||||
class CourseRunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, serializers.Serializer):
|
||||
class CourseRunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
|
||||
id = serializers.CharField(read_only=True)
|
||||
title = serializers.CharField(source='display_name')
|
||||
images = CourseRunImageSerializer(source='*', required=False)
|
||||
@@ -150,7 +150,7 @@ class CourseRunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSer
|
||||
return instance
|
||||
|
||||
|
||||
class CourseRunCreateSerializer(CourseRunSerializer):
|
||||
class CourseRunCreateSerializer(CourseRunSerializer): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
org = serializers.CharField(source='id.org')
|
||||
number = serializers.CharField(source='id.course')
|
||||
run = serializers.CharField(source='id.run')
|
||||
@@ -166,7 +166,7 @@ class CourseRunCreateSerializer(CourseRunSerializer):
|
||||
return instance
|
||||
|
||||
|
||||
class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin,
|
||||
class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
|
||||
serializers.Serializer):
|
||||
title = serializers.CharField(source='display_name', required=False)
|
||||
number = serializers.CharField(source='id.course', required=False)
|
||||
@@ -182,7 +182,7 @@ class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTe
|
||||
with store.default_store('split'):
|
||||
new_course_run_key = store.make_course_key(course_run_key.org, number, run)
|
||||
except InvalidKeyError:
|
||||
raise serializers.ValidationError(
|
||||
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
u'Invalid key supplied. Ensure there are no special characters in the Course Number.'
|
||||
)
|
||||
if store.has_course(new_course_run_key, ignore_case=True):
|
||||
|
||||
@@ -18,10 +18,10 @@ from ..utils import serialize_datetime
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class CourseRunSerializerTests(ModuleStoreTestCase):
|
||||
class CourseRunSerializerTests(ModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
|
||||
def setUp(self):
|
||||
super(CourseRunSerializerTests, self).setUp()
|
||||
super(CourseRunSerializerTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course_start = datetime.datetime.now(pytz.UTC)
|
||||
self.course_end = self.course_start + datetime.timedelta(days=30)
|
||||
|
||||
@@ -8,7 +8,7 @@ import pytz
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test import RequestFactory, override_settings
|
||||
from django.urls import reverse
|
||||
from mock import patch
|
||||
from mock import patch # lint-amnesty, pylint: disable=unused-import
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from organizations.api import add_organization, get_course_organizations
|
||||
from rest_framework.test import APIClient
|
||||
@@ -35,7 +35,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase):
|
||||
list_url = reverse('api:v1:course_run-list')
|
||||
|
||||
def setUp(self):
|
||||
super(CourseRunViewSetTests, self).setUp()
|
||||
super(CourseRunViewSetTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.client = APIClient()
|
||||
user = AdminFactory()
|
||||
self.client.login(username=user.username, password=TEST_PASSWORD)
|
||||
@@ -331,7 +331,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase):
|
||||
original_course_run = ToyCourseFactory()
|
||||
add_organization({
|
||||
'name': 'Test Organization',
|
||||
'short_name': original_course_run.id.org,
|
||||
'short_name': original_course_run.id.org, # lint-amnesty, pylint: disable=no-member
|
||||
'description': 'Testing Organization Description',
|
||||
})
|
||||
start = datetime.datetime.now(pytz.UTC).replace(microsecond=0)
|
||||
@@ -339,7 +339,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase):
|
||||
user = UserFactory()
|
||||
role = 'instructor'
|
||||
run = '3T2017'
|
||||
url = reverse('api:v1:course_run-rerun', kwargs={'pk': str(original_course_run.id)})
|
||||
url = reverse('api:v1:course_run-rerun', kwargs={'pk': str(original_course_run.id)}) # lint-amnesty, pylint: disable=no-member
|
||||
data = {
|
||||
'run': run,
|
||||
'schedule': {
|
||||
@@ -369,16 +369,16 @@ class CourseRunViewSetTests(ModuleStoreTestCase):
|
||||
|
||||
if number:
|
||||
assert course_run.id.course == number
|
||||
assert course_run.id.course != original_course_run.id.course
|
||||
assert course_run.id.course != original_course_run.id.course # lint-amnesty, pylint: disable=no-member
|
||||
else:
|
||||
assert course_run.id.course == original_course_run.id.course
|
||||
assert course_run.id.course == original_course_run.id.course # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
self.assert_course_run_schedule(course_run, start, end)
|
||||
self.assert_access_role(course_run, user, role)
|
||||
self.assert_course_access_role_count(course_run, 1)
|
||||
course_orgs = get_course_organizations(course_run_key)
|
||||
self.assertEqual(len(course_orgs), 1)
|
||||
self.assertEqual(course_orgs[0]['short_name'], original_course_run.id.org)
|
||||
self.assertEqual(course_orgs[0]['short_name'], original_course_run.id.org) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
def test_rerun_duplicate_run(self):
|
||||
course_run = ToyCourseFactory()
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
def serialize_datetime(d):
|
||||
return d.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
|
||||
|
||||
@@ -20,7 +20,7 @@ from ..serializers.course_runs import (
|
||||
)
|
||||
|
||||
|
||||
class CourseRunViewSet(viewsets.GenericViewSet):
|
||||
class CourseRunViewSet(viewsets.GenericViewSet): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
authentication_classes = (JwtAuthentication, SessionAuthentication,)
|
||||
lookup_value_regex = settings.COURSE_KEY_REGEX
|
||||
permission_classes = (permissions.IsAdminUser,)
|
||||
@@ -43,18 +43,18 @@ class CourseRunViewSet(viewsets.GenericViewSet):
|
||||
|
||||
raise Http404
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
def list(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
course_runs, __ = _accessible_courses_iter(request)
|
||||
page = self.paginate_queryset(list(course_runs))
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
def retrieve(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
course_run = self.get_object()
|
||||
serializer = self.get_serializer(course_run)
|
||||
return Response(serializer.data)
|
||||
|
||||
def update(self, request, *args, **kwargs):
|
||||
def update(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument
|
||||
course_run = self.get_object()
|
||||
|
||||
partial = kwargs.pop('partial', False)
|
||||
@@ -67,7 +67,7 @@ class CourseRunViewSet(viewsets.GenericViewSet):
|
||||
kwargs['partial'] = True
|
||||
return self.update(request, *args, **kwargs)
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
def create(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
serializer = CourseRunCreateSerializer(data=request.data, context=self.get_serializer_context())
|
||||
serializer.is_valid(raise_exception=True)
|
||||
serializer.save()
|
||||
@@ -78,7 +78,7 @@ class CourseRunViewSet(viewsets.GenericViewSet):
|
||||
methods=['post', 'put'],
|
||||
parser_classes=(parsers.FormParser, parsers.MultiPartParser,),
|
||||
serializer_class=CourseRunImageSerializer)
|
||||
def images(self, request, *args, **kwargs):
|
||||
def images(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument
|
||||
course_run = self.get_object()
|
||||
serializer = CourseRunImageSerializer(course_run, data=request.data, context=self.get_serializer_context())
|
||||
serializer.is_valid(raise_exception=True)
|
||||
@@ -86,7 +86,7 @@ class CourseRunViewSet(viewsets.GenericViewSet):
|
||||
return Response(serializer.data)
|
||||
|
||||
@action(detail=True, methods=['post'])
|
||||
def rerun(self, request, *args, **kwargs):
|
||||
def rerun(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument
|
||||
course_run = self.get_object()
|
||||
serializer = CourseRunRerunSerializer(course_run, data=request.data, context=self.get_serializer_context())
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
@@ -9,7 +9,7 @@ from uuid import uuid4
|
||||
import mock
|
||||
from boto.exception import NoAuthHandlerFound
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core import mail
|
||||
from django.test import override_settings
|
||||
from django.urls import reverse
|
||||
@@ -72,7 +72,7 @@ class TestUserTasks(APITestCase):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called
|
||||
cls.user = User.objects.create_user('test_user', 'test@example.com', 'password')
|
||||
cls.status = UserTaskStatus.objects.create(
|
||||
user=cls.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2',
|
||||
@@ -80,7 +80,7 @@ class TestUserTasks(APITestCase):
|
||||
cls.artifact = UserTaskArtifact.objects.create(status=cls.status, text='Lorem ipsum')
|
||||
|
||||
def setUp(self):
|
||||
super(TestUserTasks, self).setUp()
|
||||
super(TestUserTasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.status.refresh_from_db()
|
||||
self.client.force_authenticate(self.user) # pylint: disable=no-member
|
||||
|
||||
@@ -145,14 +145,14 @@ class TestUserTaskStopped(APITestCase):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called
|
||||
cls.user = User.objects.create_user('test_user', 'test@example.com', 'password')
|
||||
cls.status = UserTaskStatus.objects.create(
|
||||
user=cls.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2',
|
||||
total_steps=5)
|
||||
|
||||
def setUp(self):
|
||||
super(TestUserTaskStopped, self).setUp()
|
||||
super(TestUserTaskStopped, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.status.refresh_from_db()
|
||||
self.client.force_authenticate(self.user) # pylint: disable=no-member
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class CourseImportExportViewMixin(DeveloperErrorViewMixin):
|
||||
"""
|
||||
Ensures that the user is authenticated (e.g. not an AnonymousUser)
|
||||
"""
|
||||
super(CourseImportExportViewMixin, self).perform_authentication(request)
|
||||
super(CourseImportExportViewMixin, self).perform_authentication(request) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
if request.user.is_anonymous:
|
||||
raise AuthenticationFailed
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
import logging
|
||||
import time
|
||||
|
||||
@@ -128,7 +129,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
|
||||
return Response(response)
|
||||
|
||||
def _required_course_depth(self, request, all_requested):
|
||||
def _required_course_depth(self, request, all_requested): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if get_bool_param(request, 'units', all_requested):
|
||||
# The num_blocks metric for "units" requires retrieving all blocks in the graph.
|
||||
return None
|
||||
@@ -151,7 +152,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
highlights_enabled=highlights_setting.is_enabled(),
|
||||
)
|
||||
|
||||
def _subsections_quality(self, course, request):
|
||||
def _subsections_quality(self, course, request): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
subsection_unit_dict = self._get_subsections_and_units(course, request)
|
||||
num_block_types_per_subsection_dict = {}
|
||||
for subsection_key, unit_dict in six.iteritems(subsection_unit_dict):
|
||||
@@ -167,7 +168,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
num_block_types=self._stats_dict(list(six.itervalues(num_block_types_per_subsection_dict))),
|
||||
)
|
||||
|
||||
def _units_quality(self, course, request):
|
||||
def _units_quality(self, course, request): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
subsection_unit_dict = self._get_subsections_and_units(course, request)
|
||||
num_leaf_blocks_per_unit = [
|
||||
unit_info['num_leaf_blocks']
|
||||
@@ -179,7 +180,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
num_blocks=self._stats_dict(num_leaf_blocks_per_unit),
|
||||
)
|
||||
|
||||
def _videos_quality(self, course):
|
||||
def _videos_quality(self, course): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
video_blocks_in_course = modulestore().get_items(course.id, qualifiers={'category': 'video'})
|
||||
videos, __ = get_videos_for_course(course.id)
|
||||
videos_in_val = list(videos)
|
||||
@@ -227,7 +228,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
return cls._get_all_children(course)
|
||||
|
||||
@classmethod
|
||||
def _get_all_children(cls, parent):
|
||||
def _get_all_children(cls, parent): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
store = modulestore()
|
||||
children = [store.get_item(child_usage_key) for child_usage_key in cls._get_children(parent)]
|
||||
visible_children = [
|
||||
@@ -242,14 +243,14 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
return visible_chidren
|
||||
|
||||
@classmethod
|
||||
def _get_children(cls, parent):
|
||||
def _get_children(cls, parent): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if not hasattr(parent, 'children'):
|
||||
return []
|
||||
else:
|
||||
return parent.children
|
||||
|
||||
@classmethod
|
||||
def _get_leaf_blocks(cls, unit):
|
||||
def _get_leaf_blocks(cls, unit): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
def leaf_filter(block):
|
||||
return (
|
||||
block.location.block_type not in ('chapter', 'sequential', 'vertical') and
|
||||
@@ -257,11 +258,11 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
)
|
||||
|
||||
return [
|
||||
block for block in
|
||||
block for block in # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
traverse_pre_order(unit, cls._get_visible_children, leaf_filter)
|
||||
]
|
||||
|
||||
def _stats_dict(self, data):
|
||||
def _stats_dict(self, data): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if not data:
|
||||
return dict(
|
||||
min=None,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
import logging
|
||||
|
||||
import dateutil
|
||||
@@ -110,7 +111,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
has_end_date=course.end is not None,
|
||||
)
|
||||
|
||||
def _assignments_validation(self, course, request):
|
||||
def _assignments_validation(self, course, request): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
assignments, visible_assignments = self._get_assignments(course)
|
||||
assignments_with_dates = [
|
||||
a for a in visible_assignments if a.due
|
||||
@@ -218,7 +219,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
has_update=len(updates) > 0,
|
||||
)
|
||||
|
||||
def _get_assignments(self, course):
|
||||
def _get_assignments(self, course): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
store = modulestore()
|
||||
sections = [store.get_item(section_usage_key) for section_usage_key in course.children]
|
||||
assignments = [
|
||||
@@ -245,7 +246,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
oras = modulestore().get_items(course.id, qualifiers={'category': 'openassessment'})
|
||||
return oras if not graded_only else [ora for ora in oras if ora.graded]
|
||||
|
||||
def _has_date_before_start(self, ora, start):
|
||||
def _has_date_before_start(self, ora, start): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if ora.submission_start:
|
||||
if dateutil.parser.parse(ora.submission_start).replace(tzinfo=UTC) < start:
|
||||
return True
|
||||
@@ -262,7 +263,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
|
||||
return False
|
||||
|
||||
def _has_date_after_end(self, ora, end):
|
||||
def _has_date_after_end(self, ora, end): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if ora.submission_start:
|
||||
if dateutil.parser.parse(ora.submission_start).replace(tzinfo=UTC) > end:
|
||||
return True
|
||||
@@ -281,7 +282,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
|
||||
def _has_start_date(self, course):
|
||||
return not course.start_date_is_still_default
|
||||
|
||||
def _has_grading_policy(self, course):
|
||||
def _has_grading_policy(self, course): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
grading_policy_formatted = {}
|
||||
default_grading_policy_formatted = {}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class GroupConfigurationsValidationError(Exception):
|
||||
"""
|
||||
An error thrown when a group configurations input is invalid.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class GroupConfiguration(object):
|
||||
@@ -62,7 +62,7 @@ class GroupConfiguration(object):
|
||||
try:
|
||||
configuration = json.loads(json_string.decode("utf-8"))
|
||||
except ValueError:
|
||||
raise GroupConfigurationsValidationError(_("invalid JSON"))
|
||||
raise GroupConfigurationsValidationError(_("invalid JSON")) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
configuration["version"] = UserPartition.VERSION
|
||||
return configuration
|
||||
|
||||
@@ -102,7 +102,7 @@ class GroupConfiguration(object):
|
||||
"""
|
||||
Return a list of IDs that already in use.
|
||||
"""
|
||||
return set([p.id for p in get_all_partitions_for_course(course)])
|
||||
return set([p.id for p in get_all_partitions_for_course(course)]) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
|
||||
def get_user_partition(self):
|
||||
"""
|
||||
@@ -111,7 +111,7 @@ class GroupConfiguration(object):
|
||||
try:
|
||||
return UserPartition.from_json(self.configuration)
|
||||
except ReadOnlyUserPartitionError:
|
||||
raise GroupConfigurationsValidationError(_("unable to load this type of group configuration"))
|
||||
raise GroupConfigurationsValidationError(_("unable to load this type of group configuration")) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@staticmethod
|
||||
def _get_usage_dict(course, unit, item, scheme_name=None):
|
||||
|
||||
@@ -57,7 +57,7 @@ class SearchIndexingError(Exception):
|
||||
""" Indicates some error(s) occured during indexing """
|
||||
|
||||
def __init__(self, message, error_list):
|
||||
super(SearchIndexingError, self).__init__(message)
|
||||
super(SearchIndexingError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.error_list = error_list
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta):
|
||||
searcher.remove(result_ids)
|
||||
|
||||
@classmethod
|
||||
def index(cls, modulestore, structure_key, triggered_at=None, reindex_age=REINDEX_AGE, timeout=INDEXING_REQUEST_TIMEOUT):
|
||||
def index(cls, modulestore, structure_key, triggered_at=None, reindex_age=REINDEX_AGE, timeout=INDEXING_REQUEST_TIMEOUT): # lint-amnesty, pylint: disable=line-too-long, too-many-statements
|
||||
"""
|
||||
Process course for indexing
|
||||
|
||||
@@ -187,7 +187,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta):
|
||||
|
||||
item_content_groups = None
|
||||
|
||||
if item.category == "split_test":
|
||||
if item.category == "split_test": # lint-amnesty, pylint: disable=too-many-nested-blocks
|
||||
split_partition = item.get_selected_partition()
|
||||
for split_test_child in item.get_children():
|
||||
if split_partition:
|
||||
@@ -327,7 +327,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta):
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
@classmethod
|
||||
def supplemental_fields(cls, item): # pylint: disable=unused-argument
|
||||
@@ -667,7 +667,7 @@ class CourseAboutSearchIndexer(CoursewareSearchIndexer):
|
||||
return {"course": text_type(normalized_structure_key), "org": normalized_structure_key.org}
|
||||
|
||||
@classmethod
|
||||
def remove_deleted_items(cls, structure_key):
|
||||
def remove_deleted_items(cls, structure_key): # lint-amnesty, pylint: disable=arguments-differ
|
||||
""" Remove item from Course About Search_index """
|
||||
searcher = SearchEngine.get_search_engine(cls.INDEX_NAME)
|
||||
if not searcher:
|
||||
|
||||
@@ -6,9 +6,9 @@ import time
|
||||
from django.core.files.uploadhandler import FileUploadHandler
|
||||
|
||||
|
||||
class DebugFileUploader(FileUploadHandler):
|
||||
class DebugFileUploader(FileUploadHandler): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def __init__(self, request=None):
|
||||
super(DebugFileUploader, self).__init__(request)
|
||||
super(DebugFileUploader, self).__init__(request) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.count = 0
|
||||
|
||||
def receive_data_chunk(self, raw_data, start):
|
||||
|
||||
@@ -10,7 +10,7 @@ import subprocess
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from six.moves.urllib.parse import urlparse
|
||||
@@ -34,7 +34,7 @@ class GitExportError(Exception):
|
||||
|
||||
def __init__(self, message):
|
||||
# Force the lazy i18n values to turn into actual unicode objects
|
||||
super(GitExportError, self).__init__(six.text_type(message))
|
||||
super(GitExportError, self).__init__(six.text_type(message)) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
NO_EXPORT_DIR = _(u"GIT_REPO_EXPORT_DIR not set or path {0} doesn't exist, "
|
||||
"please create it, or configure a different path with "
|
||||
@@ -110,7 +110,7 @@ def export_to_git(course_id, repo, user='', rdir=None):
|
||||
branch = cmd_log(cmd, cwd).decode('utf-8').strip('\n')
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Failed to get branch: %r', ex.output)
|
||||
raise GitExportError(GitExportError.DETACHED_HEAD)
|
||||
raise GitExportError(GitExportError.DETACHED_HEAD) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
cmds = [
|
||||
['git', 'remote', 'set-url', 'origin', repo],
|
||||
@@ -129,7 +129,7 @@ def export_to_git(course_id, repo, user='', rdir=None):
|
||||
cmd_log(cmd, cwd)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Failed to pull git repository: %r', ex.output)
|
||||
raise GitExportError(GitExportError.CANNOT_PULL)
|
||||
raise GitExportError(GitExportError.CANNOT_PULL) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
# export course as xml before commiting and pushing
|
||||
root_dir = os.path.dirname(rdirp)
|
||||
@@ -139,7 +139,7 @@ def export_to_git(course_id, repo, user='', rdir=None):
|
||||
root_dir, course_dir)
|
||||
except (EnvironmentError, AttributeError):
|
||||
log.exception('Failed export to xml')
|
||||
raise GitExportError(GitExportError.XML_EXPORT_FAIL)
|
||||
raise GitExportError(GitExportError.XML_EXPORT_FAIL) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
# Get current branch if not already set
|
||||
if not branch:
|
||||
@@ -149,7 +149,7 @@ def export_to_git(course_id, repo, user='', rdir=None):
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Failed to get branch from freshly cloned repo: %r',
|
||||
ex.output)
|
||||
raise GitExportError(GitExportError.MISSING_BRANCH)
|
||||
raise GitExportError(GitExportError.MISSING_BRANCH) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
# Now that we have fresh xml exported, set identity, add
|
||||
# everything to git, commit, and push to the right branch.
|
||||
@@ -171,15 +171,15 @@ def export_to_git(course_id, repo, user='', rdir=None):
|
||||
cmd_log(['git', 'config', 'user.name', ident['name']], cwd)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Error running git configure commands: %r', ex.output)
|
||||
raise GitExportError(GitExportError.CONFIG_ERROR)
|
||||
raise GitExportError(GitExportError.CONFIG_ERROR) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
try:
|
||||
cmd_log(['git', 'add', '.'], cwd)
|
||||
cmd_log(['git', 'commit', '-a', '-m', commit_msg], cwd)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Unable to commit changes: %r', ex.output)
|
||||
raise GitExportError(GitExportError.CANNOT_COMMIT)
|
||||
raise GitExportError(GitExportError.CANNOT_COMMIT) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
try:
|
||||
cmd_log(['git', 'push', '-q', 'origin', branch], cwd)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Error running git push command: %r', ex.output)
|
||||
raise GitExportError(GitExportError.CANNOT_PUSH)
|
||||
raise GitExportError(GitExportError.CANNOT_PUSH) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@@ -32,8 +32,8 @@ class Command(BaseCommand):
|
||||
# Remove all redundant Mac OS metadata files
|
||||
assets_deleted = content_store.remove_redundant_content_for_courses()
|
||||
success = True
|
||||
except Exception as err:
|
||||
log.info("=" * 30 + u"> failed to cleanup")
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except
|
||||
log.info("=" * 30 + u"> failed to cleanup") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
log.info("Error:")
|
||||
log.info(err)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Django management command to create a course in a specific modulestore
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from six import text_type
|
||||
|
||||
@@ -53,7 +53,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
user_object = user_from_str(user)
|
||||
except User.DoesNotExist:
|
||||
raise CommandError(u"No user {user} found.".format(user=user))
|
||||
raise CommandError(u"No user {user} found.".format(user=user)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
return user_object
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
@@ -68,7 +68,7 @@ class Command(BaseCommand):
|
||||
course_key = text_type(options['course_key'])
|
||||
course_key = CourseKey.from_string(course_key)
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u'Invalid course_key: {}'.format(options['course_key']))
|
||||
raise CommandError(u'Invalid course_key: {}'.format(options['course_key'])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().get_course(course_key):
|
||||
raise CommandError(u'Course not found: {}'.format(options['course_key']))
|
||||
@@ -81,6 +81,6 @@ class Command(BaseCommand):
|
||||
|
||||
if options['remove_assets']:
|
||||
contentstore().delete_all_course_assets(course_key)
|
||||
print(u'Deleted assets for course'.format(course_key))
|
||||
print(u'Deleted assets for course'.format(course_key)) # lint-amnesty, pylint: disable=too-many-format-args
|
||||
|
||||
print(u'Deleted course {}'.format(course_key))
|
||||
|
||||
@@ -25,7 +25,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_id'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Invalid course key.")
|
||||
raise CommandError("Invalid course key.") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if options['commit']:
|
||||
print('Deleting orphans from the course:')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
###
|
||||
### Script for editing the course's tabs
|
||||
###
|
||||
@@ -37,7 +38,7 @@ def print_course(course):
|
||||
# {u'type': u'progress', u'name': u'Progress'}]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
help = """See and edit a course's tabs list. Only supports insertion
|
||||
and deletion. Move and rename etc. can be done with a delete
|
||||
followed by an insert. The tabs are numbered starting with 1.
|
||||
@@ -97,4 +98,4 @@ command again, adding --insert or --delete to edit the list.
|
||||
tabs.primitive_insert(course, num - 1, tab_type, name) # -1 as above
|
||||
except ValueError as e:
|
||||
# Cute: translate to CommandError so the CLI error prints nicely.
|
||||
raise CommandError(e)
|
||||
raise CommandError(e) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@@ -32,7 +32,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_id'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u"Invalid course_key: '%s'." % options['course_id'])
|
||||
raise CommandError(u"Invalid course_key: '%s'." % options['course_id']) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().get_course(course_key):
|
||||
raise CommandError(u"Course with %s key not found." % options['course_id'])
|
||||
|
||||
@@ -34,7 +34,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
library_key = CourseKey.from_string(options['library_id'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u'Invalid library ID: "{0}".'.format(options['library_id']))
|
||||
raise CommandError(u'Invalid library ID: "{0}".'.format(options['library_id'])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
if not isinstance(library_key, LibraryLocator):
|
||||
raise CommandError(u'Argument "{0}" is not a library key'.format(options['library_id']))
|
||||
|
||||
@@ -50,7 +50,7 @@ class Command(BaseCommand):
|
||||
# Generate archive using the handy tasks implementation
|
||||
tarball = tasks.create_export_tarball(library, library_key, {}, None)
|
||||
except Exception as e:
|
||||
raise CommandError(u'Failed to export "{0}" with "{1}"'.format(library_key, e))
|
||||
raise CommandError(u'Failed to export "{0}" with "{1}"'.format(library_key, e)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
else:
|
||||
with tarball:
|
||||
# Save generated archive with keyed filename
|
||||
|
||||
@@ -47,9 +47,9 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Unparsable course_id")
|
||||
raise CommandError("Unparsable course_id") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
except IndexError:
|
||||
raise CommandError("Insufficient arguments")
|
||||
raise CommandError("Insufficient arguments") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
filename = options['output']
|
||||
pipe_results = False
|
||||
|
||||
@@ -36,7 +36,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_key'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Invalid course key.")
|
||||
raise CommandError("Invalid course key.") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().get_course(course_key):
|
||||
raise CommandError("Course not found.")
|
||||
|
||||
@@ -6,7 +6,7 @@ Django management command to generate a test course from a course config json
|
||||
import json
|
||||
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.core.management.base import BaseCommand, CommandError
|
||||
from six import text_type
|
||||
|
||||
@@ -34,9 +34,9 @@ class Command(BaseCommand):
|
||||
try:
|
||||
courses = json.loads(options["courses_json"])["courses"]
|
||||
except ValueError:
|
||||
raise CommandError("Invalid JSON object")
|
||||
raise CommandError("Invalid JSON object") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
except KeyError:
|
||||
raise CommandError("JSON object is missing courses list")
|
||||
raise CommandError("JSON object is missing courses list") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
for course_settings in courses:
|
||||
# Validate course
|
||||
@@ -52,7 +52,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
user = user_from_str(user_email)
|
||||
except User.DoesNotExist:
|
||||
logger.warning(user_email + " user does not exist")
|
||||
logger.warning(user_email + " user does not exist") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
logger.warning("Can't create course, proceeding to next course")
|
||||
continue
|
||||
fields = self._process_course_fields(course_settings["fields"])
|
||||
@@ -102,7 +102,7 @@ class Command(BaseCommand):
|
||||
if field not in all_fields:
|
||||
# field does not exist as a CourseField
|
||||
del fields[field]
|
||||
logger.info(field + "is not a valid CourseField")
|
||||
logger.info(field + "is not a valid CourseField") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
elif fields[field] is None:
|
||||
# field is unset
|
||||
del fields[field]
|
||||
@@ -113,7 +113,7 @@ class Command(BaseCommand):
|
||||
fields[field] = Date().from_json(date_json)
|
||||
logger.info(field + " has been set to " + date_json)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logger.info("The date string could not be parsed for " + field)
|
||||
logger.info("The date string could not be parsed for " + field) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
del fields[field]
|
||||
elif field in course_tab_list_fields:
|
||||
# Generate CourseTabList object from the json value
|
||||
@@ -122,15 +122,15 @@ class Command(BaseCommand):
|
||||
fields[field] = CourseTabList().from_json(course_tab_list_json)
|
||||
logger.info(field + " has been set to " + course_tab_list_json)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logger.info("The course tab list string could not be parsed for " + field)
|
||||
logger.info("The course tab list string could not be parsed for " + field) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
del fields[field]
|
||||
else:
|
||||
# CourseField is valid and has been set
|
||||
logger.info(field + " has been set to " + str(fields[field]))
|
||||
logger.info(field + " has been set to " + str(fields[field])) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
|
||||
for field in all_fields:
|
||||
if field not in fields:
|
||||
logger.info(field + " has not been set")
|
||||
logger.info(field + " has not been set") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
return fields
|
||||
|
||||
def _course_is_valid(self, course):
|
||||
@@ -147,7 +147,7 @@ class Command(BaseCommand):
|
||||
]
|
||||
for setting in required_course_settings:
|
||||
if setting not in course:
|
||||
logger.warning("Course json is missing " + setting)
|
||||
logger.warning("Course json is missing " + setting) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
is_valid = False
|
||||
|
||||
# Check fields settings
|
||||
@@ -157,7 +157,7 @@ class Command(BaseCommand):
|
||||
if "fields" in course:
|
||||
for setting in required_field_settings:
|
||||
if setting not in course["fields"]:
|
||||
logger.warning("Fields json is missing " + setting)
|
||||
logger.warning("Fields json is missing " + setting) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
is_valid = False
|
||||
|
||||
return is_valid
|
||||
|
||||
@@ -51,7 +51,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_loc'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(text_type(git_export_utils.GitExportError.BAD_COURSE))
|
||||
raise CommandError(text_type(git_export_utils.GitExportError.BAD_COURSE)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
try:
|
||||
git_export_utils.export_to_git(
|
||||
@@ -61,4 +61,4 @@ class Command(BaseCommand):
|
||||
options.get('rdir', None)
|
||||
)
|
||||
except git_export_utils.GitExportError as ex:
|
||||
raise CommandError(text_type(ex))
|
||||
raise CommandError(text_type(ex)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@@ -8,7 +8,7 @@ import os
|
||||
import tarfile
|
||||
|
||||
from django.conf import settings
|
||||
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 SuspiciousOperation
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from lxml import etree
|
||||
@@ -52,7 +52,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
safetar_extractall(tar_file, course_dir.encode('utf-8'))
|
||||
except SuspiciousOperation as exc:
|
||||
raise CommandError(u'\n=== Course import {0}: Unsafe tar file - {1}\n'.format(archive_path, exc.args[0]))
|
||||
raise CommandError(u'\n=== Course import {0}: Unsafe tar file - {1}\n'.format(archive_path, exc.args[0])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
finally:
|
||||
tar_file.close()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ to the new split-Mongo modulestore.
|
||||
"""
|
||||
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
@@ -37,12 +37,12 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_key'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Invalid location string")
|
||||
raise CommandError("Invalid location string") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
try:
|
||||
user = user_from_str(options['email'])
|
||||
except User.DoesNotExist:
|
||||
raise CommandError(u"No user found identified by {}".format(options['email']))
|
||||
raise CommandError(u"No user found identified by {}".format(options['email'])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
return course_key, user.id, options['org'], options['course'], options['run']
|
||||
|
||||
@@ -51,7 +51,7 @@ class Command(BaseCommand):
|
||||
|
||||
migrator = SplitMigrator(
|
||||
source_modulestore=modulestore(),
|
||||
split_modulestore=modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split),
|
||||
split_modulestore=modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split), # lint-amnesty, pylint: disable=protected-access
|
||||
)
|
||||
|
||||
migrator.migrate_mongo_course(course_key, user, org, course, run)
|
||||
|
||||
@@ -47,7 +47,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
result = CourseKey.from_string(raw_value)
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u"Invalid course_key: '%s'." % raw_value)
|
||||
raise CommandError(u"Invalid course_key: '%s'." % raw_value) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not isinstance(result, CourseLocator):
|
||||
raise CommandError(u"Argument {0} is not a course key".format(raw_value))
|
||||
@@ -64,8 +64,7 @@ class Command(BaseCommand):
|
||||
setup_option = options['setup']
|
||||
index_all_courses_option = all_option or setup_option
|
||||
|
||||
if (not len(course_ids) and not index_all_courses_option) or \
|
||||
(len(course_ids) and index_all_courses_option):
|
||||
if (not len(course_ids) and not index_all_courses_option) or (len(course_ids) and index_all_courses_option): # lint-amnesty, pylint: disable=len-as-condition
|
||||
raise CommandError("reindex_course requires one or more <course_id>s OR the --all or --setup flags.")
|
||||
|
||||
store = modulestore()
|
||||
@@ -103,5 +102,5 @@ class Command(BaseCommand):
|
||||
for course_key in course_keys:
|
||||
try:
|
||||
CoursewareSearchIndexer.do_course_reindex(store, course_key)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # lint-amnesty, pylint: disable=broad-except
|
||||
logging.exception('Error indexing course %s due to the error: %s', course_key, exc)
|
||||
|
||||
@@ -5,7 +5,7 @@ integration environment.
|
||||
import logging
|
||||
from textwrap import dedent
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
@@ -37,7 +37,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
user_object = user_from_str(user)
|
||||
except User.DoesNotExist:
|
||||
raise CommandError(u"No user {user} found.".format(user=user))
|
||||
raise CommandError(u"No user {user} found.".format(user=user)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
return user_object
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
@@ -28,7 +28,7 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ExportAllCourses, self).setUp()
|
||||
super(ExportAllCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.content_store = contentstore()
|
||||
# pylint: disable=protected-access
|
||||
self.module_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
@@ -56,7 +56,7 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
# check that there are two assets ['example.txt', '.example.txt'] in contentstore for imported course
|
||||
all_assets, count = self.content_store.get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 2)
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt']))
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
|
||||
# manually add redundant assets (file ".DS_Store" and filename starts with "._")
|
||||
course_filter = course.id.make_asset_key("asset", None)
|
||||
@@ -72,11 +72,11 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
all_assets, count = self.content_store.get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 4)
|
||||
self.assertEqual(
|
||||
set([asset['_id']['name'] for asset in all_assets]),
|
||||
set([asset['_id']['name'] for asset in all_assets]), # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
set([u'.example.txt', u'example.txt', u'._example_test.txt', u'.DS_Store'])
|
||||
)
|
||||
# now call asset_cleanup command and check that there is only two proper assets in contentstore for the course
|
||||
call_command('cleanup_assets')
|
||||
all_assets, count = self.content_store.get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 2)
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt']))
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
|
||||
@@ -18,8 +18,8 @@ class TestArgParsing(TestCase):
|
||||
"""
|
||||
Tests for parsing arguments for the `create_course` management command
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestArgParsing, self).setUp()
|
||||
def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation
|
||||
super(TestArgParsing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def test_no_args(self):
|
||||
if six.PY2:
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestCourseExport(ModuleStoreTestCase):
|
||||
Test exporting a course
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestCourseExport, self).setUp()
|
||||
super(TestCourseExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Temp directories (temp_dir_1: relative path, temp_dir_2: absolute path)
|
||||
self.temp_dir_1 = mkdtemp()
|
||||
|
||||
@@ -21,8 +21,8 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ExportAllCourses, self).setUp()
|
||||
self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
super(ExportAllCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo) # lint-amnesty, pylint: disable=protected-access
|
||||
self.temp_dir = mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, self.temp_dir)
|
||||
self.first_course = CourseFactory.create(
|
||||
|
||||
@@ -78,7 +78,7 @@ class TestForcePublishModifications(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestForcePublishModifications, self).setUp()
|
||||
super(TestForcePublishModifications, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
|
||||
self.test_user_id = ModuleStoreEnum.UserID.test
|
||||
self.command = Command()
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestGitExport(CourseTestCase):
|
||||
"""
|
||||
Create/reinitialize bare repo and folders needed
|
||||
"""
|
||||
super(TestGitExport, self).setUp()
|
||||
super(TestGitExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
if not os.path.isdir(git_export_utils.GIT_REPO_EXPORT_DIR):
|
||||
os.mkdir(git_export_utils.GIT_REPO_EXPORT_DIR)
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestImport(ModuleStoreTestCase):
|
||||
Unit tests for importing a course from command line
|
||||
"""
|
||||
|
||||
def create_course_xml(self, content_dir, course_id):
|
||||
def create_course_xml(self, content_dir, course_id): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
directory = tempfile.mkdtemp(dir=content_dir)
|
||||
os.makedirs(os.path.join(directory, "course"))
|
||||
with open(os.path.join(directory, "course.xml"), "w+") as f:
|
||||
@@ -37,7 +37,7 @@ class TestImport(ModuleStoreTestCase):
|
||||
"""
|
||||
Build course XML for importing
|
||||
"""
|
||||
super(TestImport, self).setUp()
|
||||
super(TestImport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.content_dir = path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.content_dir)
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ class TestArgParsing(TestCase):
|
||||
"""
|
||||
Tests for parsing arguments for the `migrate_to_split` management command
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestArgParsing, self).setUp()
|
||||
def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation
|
||||
super(TestArgParsing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def test_no_args(self):
|
||||
"""
|
||||
@@ -64,7 +64,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestMigrateToSplit, self).setUp()
|
||||
super(TestMigrateToSplit, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory(default_store=ModuleStoreEnum.Type.mongo)
|
||||
|
||||
def test_user_email(self):
|
||||
@@ -73,11 +73,11 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
"""
|
||||
call_command(
|
||||
"migrate_to_split",
|
||||
str(self.course.id),
|
||||
str(self.course.id), # lint-amnesty, pylint: disable=no-member
|
||||
str(self.user.email),
|
||||
)
|
||||
split_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split)
|
||||
new_key = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run)
|
||||
new_key = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertTrue(
|
||||
split_store.has_course(new_key),
|
||||
"Could not find course"
|
||||
@@ -90,7 +90,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
# lack of error implies success
|
||||
call_command(
|
||||
"migrate_to_split",
|
||||
str(self.course.id),
|
||||
str(self.course.id), # lint-amnesty, pylint: disable=no-member
|
||||
str(self.user.id),
|
||||
)
|
||||
|
||||
@@ -100,7 +100,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
"""
|
||||
call_command(
|
||||
"migrate_to_split",
|
||||
str(self.course.id),
|
||||
str(self.course.id), # lint-amnesty, pylint: disable=no-member
|
||||
str(self.user.id),
|
||||
org="org.dept",
|
||||
course="name",
|
||||
@@ -113,11 +113,11 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
|
||||
# Getting the original course with mongo course_id
|
||||
mongo_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
mongo_locator = mongo_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run)
|
||||
mongo_locator = mongo_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member
|
||||
course_from_mongo = mongo_store.get_course(mongo_locator)
|
||||
self.assertIsNotNone(course_from_mongo)
|
||||
|
||||
# Throws ItemNotFoundError when try to access original course with split course_id
|
||||
split_locator = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run)
|
||||
split_locator = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member
|
||||
with self.assertRaises(ItemNotFoundError):
|
||||
mongo_store.get_course(split_locator)
|
||||
|
||||
@@ -7,7 +7,7 @@ import six
|
||||
from django.core.management import CommandError, call_command
|
||||
from six import text_type
|
||||
|
||||
from cms.djangoapps.contentstore.courseware_index import SearchIndexingError
|
||||
from cms.djangoapps.contentstore.courseware_index import SearchIndexingError # lint-amnesty, pylint: disable=unused-import
|
||||
from cms.djangoapps.contentstore.management.commands.reindex_course import Command as ReindexCommand
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -20,7 +20,7 @@ class TestReindexCourse(ModuleStoreTestCase):
|
||||
""" Tests for course reindex command """
|
||||
def setUp(self):
|
||||
""" Setup method - create courses """
|
||||
super(TestReindexCourse, self).setUp()
|
||||
super(TestReindexCourse, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.store = modulestore()
|
||||
self.first_lib = LibraryFactory.create(
|
||||
org="test", library="lib1", display_name="run1", default_store=ModuleStoreEnum.Type.split
|
||||
|
||||
@@ -20,7 +20,7 @@ class TestReindexLibrary(ModuleStoreTestCase):
|
||||
""" Tests for library reindex command """
|
||||
def setUp(self):
|
||||
""" Setup method - create libraries and courses """
|
||||
super(TestReindexLibrary, self).setUp()
|
||||
super(TestReindexLibrary, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.store = modulestore()
|
||||
self.first_lib = LibraryFactory.create(
|
||||
org="test", library="lib1", display_name="run1", default_store=ModuleStoreEnum.Type.split
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestSyncCoursesCommand(ModuleStoreTestCase):
|
||||
""" Test sync_courses command """
|
||||
|
||||
def setUp(self):
|
||||
super(TestSyncCoursesCommand, self).setUp()
|
||||
super(TestSyncCoursesCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory(username='test', email='test@example.com')
|
||||
self.catalog_course_runs = [
|
||||
@@ -32,9 +32,9 @@ class TestSyncCoursesCommand(ModuleStoreTestCase):
|
||||
|
||||
def _validate_courses(self):
|
||||
for run in self.catalog_course_runs:
|
||||
course_key = CourseKey.from_string(run.get('key'))
|
||||
course_key = CourseKey.from_string(run.get('key')) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertTrue(modulestore().has_course(course_key))
|
||||
CourseOverview.objects.get(id=run.get('key'))
|
||||
CourseOverview.objects.get(id=run.get('key')) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
def test_courses_sync(self, mock_catalog_course_runs):
|
||||
mock_catalog_course_runs.return_value = self.catalog_course_runs
|
||||
|
||||
@@ -3,7 +3,7 @@ Common methods for cms commands to use
|
||||
"""
|
||||
|
||||
|
||||
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 xmodule.modulestore.django import modulestore
|
||||
|
||||
@@ -39,7 +39,7 @@ def register_special_exams(course_key):
|
||||
|
||||
course = modulestore().get_course(course_key)
|
||||
if course is None:
|
||||
raise ItemNotFoundError(u"Course {} does not exist", six.text_type(course_key))
|
||||
raise ItemNotFoundError(u"Course {} does not exist", six.text_type(course_key)) # lint-amnesty, pylint: disable=raising-format-tuple
|
||||
|
||||
if not course.enable_proctored_exams and not course.enable_timed_exams:
|
||||
# likewise if course does not have these features turned on
|
||||
|
||||
@@ -30,7 +30,7 @@ log = logging.getLogger(__name__)
|
||||
GRADING_POLICY_COUNTDOWN_SECONDS = 3600
|
||||
|
||||
|
||||
def locked(expiry_seconds, key):
|
||||
def locked(expiry_seconds, key): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
def task_decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
|
||||
@@ -16,7 +16,7 @@ class ImportExportS3Storage(S3BotoStorage): # pylint: disable=abstract-method
|
||||
|
||||
def __init__(self):
|
||||
bucket = setting('COURSE_IMPORT_EXPORT_BUCKET', settings.AWS_STORAGE_BUCKET_NAME)
|
||||
super(ImportExportS3Storage, self).__init__(bucket=bucket, custom_domain=None, querystring_auth=True)
|
||||
super(ImportExportS3Storage, self).__init__(bucket=bucket, custom_domain=None, querystring_auth=True) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
course_import_export_storage = get_storage_class(settings.COURSE_IMPORT_EXPORT_STORAGE)()
|
||||
|
||||
@@ -16,7 +16,7 @@ from celery import shared_task
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
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 SuspiciousOperation
|
||||
from django.core.files import File
|
||||
from django.test import RequestFactory
|
||||
@@ -384,7 +384,7 @@ class CourseImportTask(UserTask): # pylint: disable=abstract-method
|
||||
|
||||
|
||||
@shared_task(base=CourseImportTask, bind=True)
|
||||
# Note: The decorator @set_code_owner_attribute could not be used because
|
||||
# Note: The decorator @set_code_owner_attribute could not be used because # lint-amnesty, pylint: disable=too-many-statements
|
||||
# the implementation of this task breaks with any additional decorators.
|
||||
def import_olx(self, user_id, course_key_string, archive_path, archive_name, language):
|
||||
"""
|
||||
|
||||
@@ -79,7 +79,7 @@ class CloneCourseTest(CourseTestCase):
|
||||
# Get & verify all assets of the course
|
||||
assets, count = contentstore().get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 1)
|
||||
self.assertEqual(set([asset['asset_key'].block_id for asset in assets]), course_assets)
|
||||
self.assertEqual(set([asset['asset_key'].block_id for asset in assets]), course_assets) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
|
||||
# rerun from split into split
|
||||
split_rerun_id = CourseLocator(org=org, course=course_number, run="2012_Q2")
|
||||
@@ -126,7 +126,7 @@ class CloneCourseTest(CourseTestCase):
|
||||
)
|
||||
|
||||
# try to hit the generic exception catch
|
||||
with patch('xmodule.modulestore.split_mongo.mongo_connection.MongoConnection.insert_course_index', Mock(side_effect=Exception)):
|
||||
with patch('xmodule.modulestore.split_mongo.mongo_connection.MongoConnection.insert_course_index', Mock(side_effect=Exception)): # lint-amnesty, pylint: disable=line-too-long
|
||||
split_course4_id = CourseLocator(org="edx3", course="split3", run="rerun_fail")
|
||||
fields = {'display_name': 'total failure'}
|
||||
CourseRerunState.objects.initiated(split_course3_id, split_course4_id, self.user, fields['display_name'])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
|
||||
|
||||
import copy
|
||||
@@ -15,8 +15,8 @@ import lxml.html
|
||||
import mock
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.middleware.csrf import _compare_salted_tokens
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.middleware.csrf import _compare_salted_tokens # lint-amnesty, pylint: disable=unused-import
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from edxval.api import create_video, get_videos_for_course
|
||||
@@ -76,7 +76,7 @@ def requires_pillow_jpeg(func):
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
raise SkipTest("Pillow is not installed (or not found)")
|
||||
raise SkipTest("Pillow is not installed (or not found)") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
if not getattr(Image.core, "jpeg_decoder", False):
|
||||
raise SkipTest("Pillow cannot open JPEG files")
|
||||
return func(*args, **kwargs)
|
||||
@@ -297,7 +297,7 @@ class ImportRequiredTestCases(ContentStoreTestCase):
|
||||
html_module = self.store.get_item(html_module_location)
|
||||
self.assertIn('/jump_to_id/nonportable_link', html_module.data)
|
||||
|
||||
def verify_content_existence(self, store, root_dir, course_id, dirname, category_name, filename_suffix=''):
|
||||
def verify_content_existence(self, store, root_dir, course_id, dirname, category_name, filename_suffix=''): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
filesystem = OSFS(root_dir / 'test_export')
|
||||
self.assertTrue(filesystem.exists(dirname))
|
||||
|
||||
@@ -614,7 +614,7 @@ class MiscCourseTests(ContentStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(MiscCourseTests, self).setUp()
|
||||
super(MiscCourseTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# save locs not items b/c the items won't have the subsequently created children in them until refetched
|
||||
self.chapter_loc = self.store.create_child(
|
||||
self.user.id, self.course.location, 'chapter', 'test_chapter'
|
||||
@@ -802,7 +802,7 @@ class MiscCourseTests(ContentStoreTestCase):
|
||||
"""Verifies rendering the editor in all the verticals in the given test course"""
|
||||
self._check_verticals([self.vert_loc])
|
||||
|
||||
def _get_draft_counts(self, item):
|
||||
def _get_draft_counts(self, item): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
cnt = 1 if getattr(item, 'is_draft', False) else 0
|
||||
for child in item.get_children():
|
||||
cnt = cnt + self._get_draft_counts(child)
|
||||
@@ -1161,7 +1161,7 @@ class ContentStoreTest(ContentStoreTestCase):
|
||||
"Please change either organization or course number to be unique.")
|
||||
|
||||
def setUp(self):
|
||||
super(ContentStoreTest, self).setUp()
|
||||
super(ContentStoreTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course_data = {
|
||||
'org': 'MITx',
|
||||
@@ -1494,7 +1494,7 @@ class ContentStoreTest(ContentStoreTestCase):
|
||||
resp = self._show_course_overview(course.id)
|
||||
self.assertContains(
|
||||
resp,
|
||||
'<article class="outline outline-complex outline-course" data-locator="{locator}" data-course-key="{course_key}">'.format(
|
||||
'<article class="outline outline-complex outline-course" data-locator="{locator}" data-course-key="{course_key}">'.format( # lint-amnesty, pylint: disable=line-too-long
|
||||
locator=text_type(course.location),
|
||||
course_key=text_type(course.id),
|
||||
),
|
||||
@@ -1536,7 +1536,7 @@ class ContentStoreTest(ContentStoreTestCase):
|
||||
self.assertIsInstance(problem, ProblemBlock, "New problem is not a ProblemBlock")
|
||||
context = problem.get_context()
|
||||
self.assertIn('markdown', context, "markdown is missing from context")
|
||||
self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields")
|
||||
self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields") # lint-amnesty, pylint: disable=line-too-long
|
||||
|
||||
def test_cms_imported_course_walkthrough(self):
|
||||
"""
|
||||
@@ -1806,7 +1806,7 @@ class MetadataSaveTestCase(ContentStoreTestCase):
|
||||
"""Test that metadata is correctly cached and decached."""
|
||||
|
||||
def setUp(self):
|
||||
super(MetadataSaveTestCase, self).setUp()
|
||||
super(MetadataSaveTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
course = CourseFactory.create()
|
||||
|
||||
@@ -1866,7 +1866,7 @@ class RerunCourseTest(ContentStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(RerunCourseTest, self).setUp()
|
||||
super(RerunCourseTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.destination_course_data = {
|
||||
'org': 'MITx',
|
||||
'number': '111',
|
||||
@@ -2174,7 +2174,7 @@ class EntryPageTestCase(TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(EntryPageTestCase, self).setUp()
|
||||
super(EntryPageTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.client = AjaxEnabledTestClient()
|
||||
|
||||
def _test_page(self, page, status_code=200):
|
||||
|
||||
@@ -37,7 +37,7 @@ class TestCourseListing(ModuleStoreTestCase):
|
||||
"""
|
||||
Add a user and a course
|
||||
"""
|
||||
super(TestCourseListing, self).setUp()
|
||||
super(TestCourseListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# create and log in a staff user.
|
||||
# create and log in a non-staff user
|
||||
self.user = UserFactory()
|
||||
|
||||
@@ -51,7 +51,7 @@ class TestCourseListing(ModuleStoreTestCase):
|
||||
"""
|
||||
Add a user and a course
|
||||
"""
|
||||
super(TestCourseListing, self).setUp()
|
||||
super(TestCourseListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# create and log in a staff user.
|
||||
# create and log in a non-staff user
|
||||
self.user = UserFactory()
|
||||
|
||||
@@ -100,7 +100,7 @@ class CourseAdvanceSettingViewTest(CourseTestCase, MilestonesTestCaseMixin):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CourseAdvanceSettingViewTest, self).setUp()
|
||||
super(CourseAdvanceSettingViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.fullcourse = CourseFactory.create()
|
||||
self.course_setting_url = get_url(self.course.id, 'advanced_settings_handler')
|
||||
|
||||
@@ -916,7 +916,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CourseMetadataEditingTest, self).setUp()
|
||||
super(CourseMetadataEditingTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.fullcourse = CourseFactory.create()
|
||||
self.course_setting_url = get_url(self.course.id, 'advanced_settings_handler')
|
||||
self.fullcourse_setting_url = get_url(self.fullcourse.id, 'advanced_settings_handler')
|
||||
@@ -1175,7 +1175,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
self.assertEqual(len(errors), 3)
|
||||
self.assertFalse(test_model)
|
||||
|
||||
error_keys = set([error_obj['model']['display_name'] for error_obj in errors])
|
||||
error_keys = set([error_obj['model']['display_name'] for error_obj in errors]) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
test_keys = set(['Advanced Module List', 'Course Advertised Start Date', 'Days Early for Beta Users'])
|
||||
self.assertEqual(error_keys, test_keys)
|
||||
|
||||
@@ -1527,7 +1527,7 @@ class CourseGraderUpdatesTest(CourseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""Compute the url to use in tests"""
|
||||
super(CourseGraderUpdatesTest, self).setUp()
|
||||
super(CourseGraderUpdatesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = get_url(self.course.id, 'grading_handler')
|
||||
self.starting_graders = CourseGradingModel(self.course).graders
|
||||
|
||||
@@ -1625,7 +1625,7 @@ id=\"course-enrollment-end-time\" value=\"\" placeholder=\"HH:MM\" autocomplete=
|
||||
"""
|
||||
Initialize course used to test enrollment fields.
|
||||
"""
|
||||
super(CourseEnrollmentEndFieldTest, self).setUp()
|
||||
super(CourseEnrollmentEndFieldTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(org='edX', number='dummy', display_name='Marketing Site Course')
|
||||
self.course_details_url = reverse_course_url('settings_handler', six.text_type(self.course.id))
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from mock import patch
|
||||
from pytz import UTC
|
||||
from search.search_engine_base import SearchEngine
|
||||
from six.moves import range
|
||||
from xblock.core import XBlock
|
||||
from xblock.core import XBlock # lint-amnesty, pylint: disable=unused-import
|
||||
|
||||
from cms.djangoapps.contentstore.courseware_index import (
|
||||
CourseAboutSearchIndexer,
|
||||
@@ -71,7 +71,7 @@ def create_children(store, parent, category, load_factor):
|
||||
child_object = ItemFactory.create(
|
||||
parent_location=parent.location,
|
||||
category=category,
|
||||
display_name=u"{} {} {}".format(category, child_index, time.clock()),
|
||||
display_name=u"{} {} {}".format(category, child_index, time.clock()), # lint-amnesty, pylint: disable=no-member
|
||||
modulestore=store,
|
||||
publish_item=True,
|
||||
start=datetime(2015, 3, 1, tzinfo=UTC),
|
||||
@@ -140,7 +140,7 @@ class MixedWithOptionsTestCase(MixedSplitTestCase):
|
||||
|
||||
def setup_course_base(self, store):
|
||||
""" base version of setup_course_base is a no-op """
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
@lazy
|
||||
def searcher(self):
|
||||
@@ -195,7 +195,7 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
|
||||
WORKS_WITH_STORES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
|
||||
|
||||
def setUp(self):
|
||||
super(TestCoursewareSearchIndexer, self).setUp()
|
||||
super(TestCoursewareSearchIndexer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = None
|
||||
self.chapter = None
|
||||
@@ -605,11 +605,11 @@ class TestLargeCourseDeletions(MixedWithOptionsTestCase):
|
||||
self.course_id = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestLargeCourseDeletions, self).setUp()
|
||||
super(TestLargeCourseDeletions, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_id = None
|
||||
|
||||
def tearDown(self):
|
||||
super(TestLargeCourseDeletions, self).tearDown()
|
||||
super(TestLargeCourseDeletions, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self._clean_course_id()
|
||||
|
||||
def assert_search_count(self, expected_count):
|
||||
@@ -787,7 +787,7 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase):
|
||||
WORKS_WITH_STORES = (ModuleStoreEnum.Type.split, )
|
||||
|
||||
def setUp(self):
|
||||
super(TestLibrarySearchIndexer, self).setUp()
|
||||
super(TestLibrarySearchIndexer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.library = None
|
||||
self.html_unit1 = None
|
||||
@@ -937,7 +937,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase):
|
||||
INDEX_NAME = CoursewareSearchIndexer.INDEX_NAME
|
||||
|
||||
def setUp(self):
|
||||
super(GroupConfigurationSearchMongo, self).setUp()
|
||||
super(GroupConfigurationSearchMongo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self._setup_course_with_content()
|
||||
self._setup_split_test_module()
|
||||
@@ -1427,7 +1427,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase):
|
||||
mock_index.reset_mock()
|
||||
|
||||
|
||||
class GroupConfigurationSearchSplit(GroupConfigurationSearchMongo):
|
||||
class GroupConfigurationSearchSplit(GroupConfigurationSearchMongo): # lint-amnesty, pylint: disable=test-inherits-tests
|
||||
"""
|
||||
Tests indexing of content groups on course modules using split modulestore.
|
||||
"""
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestExportGit(CourseTestCase):
|
||||
"""
|
||||
Setup test course, user, and url.
|
||||
"""
|
||||
super(TestExportGit, self).setUp()
|
||||
super(TestExportGit, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_module = modulestore().get_course(self.course.id)
|
||||
self.test_url = reverse_course_url('export_git', self.course.id)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestHandleItemDeleted(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
"""
|
||||
Initial data setup
|
||||
"""
|
||||
super(TestHandleItemDeleted, self).setUp()
|
||||
super(TestHandleItemDeleted, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
self.course.enable_subsection_gating = True
|
||||
|
||||
@@ -8,7 +8,7 @@ import gettext
|
||||
from unittest import skip
|
||||
|
||||
import mock
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.utils import translation
|
||||
from django.utils.translation import get_language
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestModuleI18nService(ModuleStoreTestCase):
|
||||
|
||||
def setUp(self):
|
||||
""" Setting up tests """
|
||||
super(TestModuleI18nService, self).setUp()
|
||||
super(TestModuleI18nService, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.test_language = 'dummy language'
|
||||
self.request = mock.Mock()
|
||||
self.course = CourseFactory.create()
|
||||
@@ -187,7 +187,7 @@ class InternationalizationTest(ModuleStoreTestCase):
|
||||
will be cleared out before each test case execution and deleted
|
||||
afterwards.
|
||||
"""
|
||||
super(InternationalizationTest, self).setUp()
|
||||
super(InternationalizationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.uname = 'testuser'
|
||||
self.email = 'test+courses@edx.org'
|
||||
@@ -211,7 +211,7 @@ class InternationalizationTest(ModuleStoreTestCase):
|
||||
|
||||
def test_course_plain_english(self):
|
||||
"""Test viewing the index page with no courses"""
|
||||
self.client = AjaxEnabledTestClient()
|
||||
self.client = AjaxEnabledTestClient() # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
self.client.login(username=self.uname, password=self.password)
|
||||
|
||||
resp = self.client.get_html('/home/')
|
||||
@@ -222,7 +222,7 @@ class InternationalizationTest(ModuleStoreTestCase):
|
||||
|
||||
def test_course_explicit_english(self):
|
||||
"""Test viewing the index page with no courses"""
|
||||
self.client = AjaxEnabledTestClient()
|
||||
self.client = AjaxEnabledTestClient() # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
self.client.login(username=self.uname, password=self.password)
|
||||
|
||||
resp = self.client.get_html(
|
||||
@@ -247,7 +247,7 @@ class InternationalizationTest(ModuleStoreTestCase):
|
||||
@skip
|
||||
def test_course_with_accents(self):
|
||||
"""Test viewing the index page with no courses"""
|
||||
self.client = AjaxEnabledTestClient()
|
||||
self.client = AjaxEnabledTestClient() # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
self.client.login(username=self.uname, password=self.password)
|
||||
|
||||
resp = self.client.get_html(
|
||||
|
||||
@@ -37,7 +37,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
|
||||
NOTE: refactor using CourseFactory so they do not.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(ContentStoreImportTest, self).setUp()
|
||||
super(ContentStoreImportTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.client = Client()
|
||||
self.client.login(username=self.user.username, password=self.user_password)
|
||||
@@ -48,7 +48,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.task_patcher.stop()
|
||||
super(ContentStoreImportTest, self).tearDown()
|
||||
super(ContentStoreImportTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def load_test_import_course(self, target_id=None, create_if_not_present=True, module_store=None):
|
||||
'''
|
||||
@@ -252,7 +252,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
|
||||
{"0": '9f0941d021414798836ef140fb5f6841', "1": '0faf29473cf1497baa33fcc828b179cd'},
|
||||
)
|
||||
|
||||
def _verify_split_test_import(self, target_course_name, source_course_name, split_test_name, groups_to_verticals):
|
||||
def _verify_split_test_import(self, target_course_name, source_course_name, split_test_name, groups_to_verticals): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
module_store = modulestore()
|
||||
target_id = module_store.make_course_key('testX', target_course_name, 'copy_run')
|
||||
import_course_from_xml(
|
||||
|
||||
@@ -14,7 +14,7 @@ TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
|
||||
|
||||
# This test is in the CMS module because the test configuration to use a draft
|
||||
# modulestore is dependent on django.
|
||||
class DraftReorderTestCase(ModuleStoreTestCase):
|
||||
class DraftReorderTestCase(ModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
|
||||
def test_order(self):
|
||||
"""
|
||||
|
||||
@@ -41,7 +41,7 @@ class LibraryTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(LibraryTestCase, self).setUp()
|
||||
super(LibraryTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory(password=self.user_password, is_staff=True)
|
||||
self.client = AjaxEnabledTestClient()
|
||||
@@ -504,7 +504,7 @@ class TestLibraryAccess(LibraryTestCase):
|
||||
|
||||
def setUp(self):
|
||||
""" Create a library, staff user, and non-staff user """
|
||||
super(TestLibraryAccess, self).setUp()
|
||||
super(TestLibraryAccess, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.non_staff_user_password = 'foo'
|
||||
self.non_staff_user = UserFactory(password=self.non_staff_user_password, is_staff=False)
|
||||
|
||||
@@ -544,7 +544,7 @@ class TestLibraryAccess(LibraryTestCase):
|
||||
Log out when done each test
|
||||
"""
|
||||
self.client.logout()
|
||||
super(TestLibraryAccess, self).tearDown()
|
||||
super(TestLibraryAccess, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def test_creation(self):
|
||||
"""
|
||||
@@ -837,7 +837,7 @@ class TestOverrides(LibraryTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestOverrides, self).setUp()
|
||||
super(TestOverrides, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.original_display_name = "A Problem Block"
|
||||
self.original_weight = 1
|
||||
|
||||
@@ -1022,7 +1022,7 @@ class TestIncompatibleModuleStore(LibraryTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestIncompatibleModuleStore, self).setUp()
|
||||
super(TestIncompatibleModuleStore, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# Create a course in an incompatible modulestore.
|
||||
with modulestore().default_store(ModuleStoreEnum.Type.mongo):
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
@@ -5,7 +5,7 @@ Test CRUD for authorization.
|
||||
|
||||
import copy
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from six.moves import range
|
||||
|
||||
from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient
|
||||
@@ -25,7 +25,7 @@ class TestCourseAccess(ModuleStoreTestCase):
|
||||
|
||||
Create a pool of users w/o granting them any permissions
|
||||
"""
|
||||
super(TestCourseAccess, self).setUp()
|
||||
super(TestCourseAccess, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.client = AjaxEnabledTestClient()
|
||||
self.client.login(username=self.user.username, password=self.user_password)
|
||||
@@ -94,7 +94,7 @@ class TestCourseAccess(ModuleStoreTestCase):
|
||||
user = users.pop()
|
||||
group.add_users(user)
|
||||
user_by_role[role].append(user)
|
||||
self.assertTrue(auth.has_course_author_access(user, self.course_key), "{} does not have access".format(user))
|
||||
self.assertTrue(auth.has_course_author_access(user, self.course_key), "{} does not have access".format(user)) # lint-amnesty, pylint: disable=line-too-long
|
||||
|
||||
course_team_url = reverse_course_url('course_team_handler', self.course_key)
|
||||
response = self.client.get_html(course_team_url)
|
||||
@@ -132,4 +132,4 @@ class TestCourseAccess(ModuleStoreTestCase):
|
||||
auth.remove_users(self.user, role(self.course_key.org), user)
|
||||
else:
|
||||
auth.remove_users(self.user, role(self.course_key), user)
|
||||
self.assertFalse(auth.has_course_author_access(user, self.course_key), u"{} remove didn't work".format(user))
|
||||
self.assertFalse(auth.has_course_author_access(user, self.course_key), u"{} remove didn't work".format(user)) # lint-amnesty, pylint: disable=line-too-long
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestProctoredExams(ModuleStoreTestCase):
|
||||
"""
|
||||
Initial data setup
|
||||
"""
|
||||
super(TestProctoredExams, self).setUp()
|
||||
super(TestProctoredExams, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
org='edX',
|
||||
|
||||
@@ -17,7 +17,7 @@ class LockedTest(ModuleStoreTestCase):
|
||||
"""Test class to verify locking of mocked resources"""
|
||||
|
||||
def setUp(self):
|
||||
super(LockedTest, self).setUp()
|
||||
super(LockedTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(
|
||||
org='edx',
|
||||
name='course',
|
||||
|
||||
@@ -9,7 +9,7 @@ from uuid import uuid4
|
||||
|
||||
import mock
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.test.utils import override_settings
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from organizations.models import OrganizationCourse
|
||||
@@ -114,7 +114,7 @@ class ExportLibraryTestCase(LibraryTestCase):
|
||||
|
||||
|
||||
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
|
||||
class RerunCourseTaskTestCase(CourseTestCase):
|
||||
class RerunCourseTaskTestCase(CourseTestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def _rerun_course(self, old_course_key, new_course_key):
|
||||
CourseRerunState.objects.initiated(old_course_key, new_course_key, self.user, 'Test Re-run')
|
||||
rerun_course(str(old_course_key), str(new_course_key), self.user.id)
|
||||
|
||||
@@ -33,7 +33,7 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().
|
||||
class TestGenerateSubs(unittest.TestCase):
|
||||
"""Tests for `generate_subs` function."""
|
||||
def setUp(self):
|
||||
super(TestGenerateSubs, self).setUp()
|
||||
super(TestGenerateSubs, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.source_subs = {
|
||||
'start': [100, 200, 240, 390, 1000],
|
||||
@@ -138,7 +138,7 @@ class TestSaveSubsToStore(SharedModuleStoreTestCase):
|
||||
cls.content_location_unjsonable = cls.sub_id_to_location(cls.unjsonable_subs_id)
|
||||
|
||||
def setUp(self):
|
||||
super(TestSaveSubsToStore, self).setUp()
|
||||
super(TestSaveSubsToStore, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.addCleanup(self.clear_subs_content)
|
||||
self.clear_subs_content()
|
||||
|
||||
@@ -188,7 +188,7 @@ class TestYoutubeSubsBase(SharedModuleStoreTestCase):
|
||||
def setUpClass(cls):
|
||||
super(TestYoutubeSubsBase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(
|
||||
org=cls.org, number=cls.number, display_name=cls.display_name)
|
||||
org=cls.org, number=cls.number, display_name=cls.display_name) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
|
||||
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
|
||||
@@ -280,7 +280,7 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase):
|
||||
transcripts_utils.download_youtube_subs(good_youtube_sub, self.course, settings)
|
||||
|
||||
# Check assets status after importing subtitles.
|
||||
for subs_id in good_youtube_subs.values():
|
||||
for subs_id in good_youtube_subs.values(): # lint-amnesty, pylint: disable=undefined-variable
|
||||
filename = 'subs_{0}.srt.sjson'.format(subs_id)
|
||||
content_location = StaticContent.compute_location(
|
||||
self.course.id, filename
|
||||
@@ -355,7 +355,7 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase):
|
||||
)
|
||||
|
||||
|
||||
class TestGenerateSubsFromSource(TestDownloadYoutubeSubs):
|
||||
class TestGenerateSubsFromSource(TestDownloadYoutubeSubs): # lint-amnesty, pylint: disable=test-inherits-tests
|
||||
"""Tests for `generate_subs_from_source` function."""
|
||||
|
||||
def test_success_generating_subs(self):
|
||||
@@ -426,7 +426,7 @@ class TestGenerateSubsFromSource(TestDownloadYoutubeSubs):
|
||||
self.assertEqual(exception_message, "Something wrong with SubRip transcripts file during parsing.")
|
||||
|
||||
|
||||
class TestGenerateSrtFromSjson(TestDownloadYoutubeSubs):
|
||||
class TestGenerateSrtFromSjson(TestDownloadYoutubeSubs): # lint-amnesty, pylint: disable=test-inherits-tests
|
||||
"""Tests for `generate_srt_from_sjson` function."""
|
||||
|
||||
def test_success_generating_subs(self):
|
||||
@@ -561,7 +561,7 @@ class TestTranscript(unittest.TestCase):
|
||||
Tests for Transcript class e.g. different transcript conversions.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestTranscript, self).setUp()
|
||||
super(TestTranscript, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.srt_transcript = textwrap.dedent("""\
|
||||
0
|
||||
@@ -710,7 +710,7 @@ class TestGetTranscript(SharedModuleStoreTestCase):
|
||||
"""Tests for `get_transcript` function."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestGetTranscript, self).setUp()
|
||||
super(TestGetTranscript, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class TestUsersDefaultRole(ModuleStoreTestCase):
|
||||
"""
|
||||
Add a user and a course
|
||||
"""
|
||||
super(TestUsersDefaultRole, self).setUp()
|
||||
super(TestUsersDefaultRole, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# create and log in a staff user.
|
||||
self.user = UserFactory(is_staff=True)
|
||||
self.client = AjaxEnabledTestClient()
|
||||
@@ -49,7 +49,7 @@ class TestUsersDefaultRole(ModuleStoreTestCase):
|
||||
Reverse the setup
|
||||
"""
|
||||
self.client.logout()
|
||||
super(TestUsersDefaultRole, self).tearDown()
|
||||
super(TestUsersDefaultRole, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def test_user_forum_default_role_on_course_deletion(self):
|
||||
"""
|
||||
|
||||
@@ -168,7 +168,7 @@ class ReleaseDateSourceTest(CourseTestCase):
|
||||
"""Tests for finding the source of an xblock's release date."""
|
||||
|
||||
def setUp(self):
|
||||
super(ReleaseDateSourceTest, self).setUp()
|
||||
super(ReleaseDateSourceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
|
||||
self.sequential = ItemFactory.create(category='sequential', parent_location=self.chapter.location)
|
||||
@@ -222,7 +222,7 @@ class StaffLockTest(CourseTestCase):
|
||||
"""Base class for testing staff lock functions."""
|
||||
|
||||
def setUp(self):
|
||||
super(StaffLockTest, self).setUp()
|
||||
super(StaffLockTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
|
||||
self.sequential = ItemFactory.create(category='sequential', parent_location=self.chapter.location)
|
||||
@@ -332,7 +332,7 @@ class GroupVisibilityTest(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(GroupVisibilityTest, self).setUp()
|
||||
super(GroupVisibilityTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
|
||||
sequential = ItemFactory.create(category='sequential', parent_location=chapter.location)
|
||||
@@ -432,7 +432,7 @@ class GetUserPartitionInfoTest(ModuleStoreTestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""Create a dummy course. """
|
||||
super(GetUserPartitionInfoTest, self).setUp()
|
||||
super(GetUserPartitionInfoTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory()
|
||||
self.block = ItemFactory.create(category="problem", parent_location=self.course.location)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(ScrapeVideoThumbnailsTestCase, self).setUp()
|
||||
super(ScrapeVideoThumbnailsTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
course_ids = [six.text_type(self.course.id)]
|
||||
profiles = ['youtube']
|
||||
created = datetime.now(pytz.utc)
|
||||
@@ -214,7 +214,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase):
|
||||
mocked_responses = []
|
||||
for resolution in YOUTUBE_THUMBNAIL_SIZES:
|
||||
mocked_content = resolutions.get(resolution, '')
|
||||
error_response = False if mocked_content else True
|
||||
error_response = False if mocked_content else True # lint-amnesty, pylint: disable=simplifiable-if-expression
|
||||
mocked_responses.append(self.mocked_youtube_thumbnail_response(mocked_content, error_response))
|
||||
return mocked_responses
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class AuthTestCase(ContentStoreTestCase):
|
||||
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']
|
||||
|
||||
def setUp(self):
|
||||
super(AuthTestCase, self).setUp()
|
||||
super(AuthTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.email = 'a@b.com'
|
||||
self.pw = 'xyz'
|
||||
@@ -191,7 +191,7 @@ class ForumTestCase(CourseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
""" Creates the test course. """
|
||||
super(ForumTestCase, self).setUp()
|
||||
super(ForumTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(org='testX', number='727', display_name='Forum Course')
|
||||
|
||||
def set_blackout_dates(self, blackout_dates):
|
||||
@@ -242,7 +242,7 @@ class CourseKeyVerificationTestCase(CourseTestCase):
|
||||
"""
|
||||
Create test course.
|
||||
"""
|
||||
super(CourseKeyVerificationTestCase, self).setUp()
|
||||
super(CourseKeyVerificationTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(org='edX', number='test_course_key', display_name='Test Course')
|
||||
|
||||
@data(('edX/test_course_key/Test_Course', 200), ('garbage:edX+test_course_key+Test_Course', 404))
|
||||
|
||||
@@ -8,7 +8,7 @@ import textwrap
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.test.client import Client
|
||||
from mock import Mock
|
||||
from opaque_keys.edx.keys import AssetKey, CourseKey
|
||||
@@ -84,7 +84,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
|
||||
afterwards.
|
||||
"""
|
||||
|
||||
super(CourseTestCase, self).setUp()
|
||||
super(CourseTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.client = AjaxEnabledTestClient()
|
||||
self.client.login(username=self.user.username, password=self.user_password)
|
||||
@@ -285,8 +285,8 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
|
||||
course2_items = self.store.get_items(course2_id)
|
||||
self.assertGreater(len(course1_items), 0) # ensure it found content instead of [] == []
|
||||
if len(course1_items) != len(course2_items):
|
||||
course1_block_ids = set([item.location.block_id for item in course1_items])
|
||||
course2_block_ids = set([item.location.block_id for item in course2_items])
|
||||
course1_block_ids = set([item.location.block_id for item in course1_items]) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
course2_block_ids = set([item.location.block_id for item in course2_items]) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
raise AssertionError(
|
||||
u"Course1 extra blocks: {}; course2 extra blocks: {}".format(
|
||||
course1_block_ids - course2_block_ids, course2_block_ids - course1_block_ids
|
||||
|
||||
@@ -99,7 +99,7 @@ def _remove_instructors(course_key):
|
||||
|
||||
try:
|
||||
remove_all_instructors(course_key)
|
||||
except Exception as err:
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except
|
||||
log.error(u"Error in deleting course groups for {0}: {1}".format(course_key, err))
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ def is_currently_visible_to_students(xblock):
|
||||
return False
|
||||
|
||||
# Check start date
|
||||
if 'detached' not in published._class_tags and published.start is not None:
|
||||
if 'detached' not in published._class_tags and published.start is not None: # lint-amnesty, pylint: disable=protected-access
|
||||
return datetime.now(UTC) > published.start
|
||||
|
||||
# No start date, so it's always visible
|
||||
|
||||
@@ -117,7 +117,7 @@ def validate_and_update_video_image(course_key_string, edx_video_id, image_file,
|
||||
|
||||
update_video_image(edx_video_id, course_key_string, image_file, image_filename)
|
||||
LOGGER.info(
|
||||
u'VIDEOS: Scraping youtube video thumbnail for edx_video_id [%s] in course [%s]', edx_video_id, course_key_string
|
||||
u'VIDEOS: Scraping youtube video thumbnail for edx_video_id [%s] in course [%s]', edx_video_id, course_key_string # lint-amnesty, pylint: disable=line-too-long
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from .assets import *
|
||||
from .checklists import *
|
||||
from .component import *
|
||||
from .course import *
|
||||
from .course import * # lint-amnesty, pylint: disable=redefined-builtin
|
||||
from .entrance_exam import *
|
||||
from .error import *
|
||||
from .export_git import *
|
||||
|
||||
@@ -150,7 +150,7 @@ def _assets_json(request, course_key):
|
||||
|
||||
assets, total_count = _get_assets_for_page(course_key, query_options)
|
||||
|
||||
if request_options['requested_page'] > 0 and first_asset_to_display_index >= total_count and total_count > 0:
|
||||
if request_options['requested_page'] > 0 and first_asset_to_display_index >= total_count and total_count > 0: # lint-amnesty, pylint: disable=chained-comparison
|
||||
_update_options_to_requery_final_page(query_options, total_count)
|
||||
current_page = query_options['current_page']
|
||||
first_asset_to_display_index = _get_first_asset_index(current_page, requested_page_size)
|
||||
@@ -432,7 +432,7 @@ def _upload_asset(request, course_key):
|
||||
})
|
||||
|
||||
|
||||
def _get_error_if_course_does_not_exist(course_key):
|
||||
def _get_error_if_course_does_not_exist(course_key): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
try:
|
||||
modulestore().get_course(course_key)
|
||||
except ItemNotFoundError:
|
||||
@@ -440,7 +440,7 @@ def _get_error_if_course_does_not_exist(course_key):
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
|
||||
def _get_file_metadata_as_dictionary(upload_file):
|
||||
def _get_file_metadata_as_dictionary(upload_file): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
# compute a 'filename' which is similar to the location formatting; we're
|
||||
# using the 'filename' nomenclature since we're using a FileSystem paradigm
|
||||
# here; we're just imposing the Location string formatting expectations to
|
||||
@@ -564,15 +564,15 @@ def delete_asset(course_key, asset_key):
|
||||
del_cached_content(content.location)
|
||||
|
||||
|
||||
def _check_existence_and_get_asset_content(asset_key):
|
||||
def _check_existence_and_get_asset_content(asset_key): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
try:
|
||||
content = contentstore().find(asset_key)
|
||||
return content
|
||||
except NotFoundError:
|
||||
raise AssetNotFoundException
|
||||
raise AssetNotFoundException # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
|
||||
def _delete_thumbnail(thumbnail_location, course_key, asset_key):
|
||||
def _delete_thumbnail(thumbnail_location, course_key, asset_key): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if thumbnail_location is not None:
|
||||
|
||||
# We are ignoring the value of the thumbnail_location-- we only care whether
|
||||
|
||||
@@ -113,14 +113,14 @@ class CertificateException(Exception):
|
||||
"""
|
||||
Base exception for Certificates workflows
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class CertificateValidationError(CertificateException):
|
||||
"""
|
||||
An exception raised when certificate information is invalid.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class CertificateManager(object):
|
||||
@@ -136,7 +136,7 @@ class CertificateManager(object):
|
||||
try:
|
||||
certificate = json.loads(json_string)
|
||||
except ValueError:
|
||||
raise CertificateValidationError(_("invalid JSON"))
|
||||
raise CertificateValidationError(_("invalid JSON")) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
# Include the data contract version
|
||||
certificate["version"] = CERTIFICATE_SCHEMA_VERSION
|
||||
# Ensure a signatories list is always returned
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
|
||||
@@ -113,7 +113,7 @@ def container_handler(request, usage_key_string):
|
||||
try:
|
||||
usage_key = UsageKey.from_string(usage_key_string)
|
||||
except InvalidKeyError: # Raise Http404 on invalid 'usage_key_string'
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
with modulestore().bulk_operations(usage_key.course_key):
|
||||
try:
|
||||
course, xblock, lms_link, preview_lms_link = _get_item_in_course(request, usage_key)
|
||||
@@ -208,7 +208,7 @@ def container_handler(request, usage_key_string):
|
||||
return HttpResponseBadRequest("Only supports HTML requests")
|
||||
|
||||
|
||||
def get_component_templates(courselike, library=False):
|
||||
def get_component_templates(courselike, library=False): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Returns the applicable component templates that can be used by the specified course or library.
|
||||
"""
|
||||
@@ -298,7 +298,7 @@ def get_component_templates(courselike, library=False):
|
||||
# Content Libraries currently don't allow opting in to unsupported xblocks/problem types.
|
||||
allow_unsupported = getattr(courselike, "allow_unsupported_xblocks", False)
|
||||
|
||||
for category in component_types:
|
||||
for category in component_types: # lint-amnesty, pylint: disable=too-many-nested-blocks
|
||||
authorable_variations = authorable_xblocks(allow_unsupported=allow_unsupported, name=category)
|
||||
support_level_without_template = component_support_level(authorable_variations, category)
|
||||
templates_for_category = []
|
||||
@@ -338,7 +338,7 @@ def get_component_templates(courselike, library=False):
|
||||
|
||||
templates_for_category.append(
|
||||
create_template_dict(
|
||||
_(template['metadata'].get('display_name')),
|
||||
_(template['metadata'].get('display_name')), # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
category,
|
||||
support_level_with_template,
|
||||
template_id,
|
||||
@@ -504,7 +504,7 @@ def component_handler(request, usage_key_string, handler, suffix=''):
|
||||
resp = handler_descriptor.handle(handler, req, suffix)
|
||||
except NoSuchHandlerError:
|
||||
log.info(u"XBlock %s attempted to access missing handler %r", handler_descriptor, handler, exc_info=True)
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
# unintentional update to handle any side effects of handle call
|
||||
# could potentially be updating actual course data or simply caching its values
|
||||
|
||||
@@ -133,7 +133,7 @@ class AccessListFallback(Exception):
|
||||
An exception that is raised whenever we need to `fall back` to fetching *all* courses
|
||||
available to a user, rather than using a shorter method (i.e. fetching by group)
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
def get_course_and_check_access(course_key, user, depth=0):
|
||||
@@ -289,7 +289,7 @@ def course_handler(request, course_key_string=None):
|
||||
else:
|
||||
return HttpResponseNotFound()
|
||||
except InvalidKeyError:
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -357,7 +357,7 @@ def _course_outline_json(request, course_module):
|
||||
return create_xblock_info(
|
||||
course_module,
|
||||
include_child_info=True,
|
||||
course_outline=False if is_concise else True,
|
||||
course_outline=False if is_concise else True, # lint-amnesty, pylint: disable=simplifiable-if-expression
|
||||
include_children_predicate=include_children_predicate,
|
||||
is_concise=is_concise,
|
||||
user=request.user
|
||||
@@ -531,8 +531,8 @@ def course_listing(request):
|
||||
u'org': uca.course_key.org,
|
||||
u'number': uca.course_key.course,
|
||||
u'run': uca.course_key.run,
|
||||
u'is_failed': True if uca.state == CourseRerunUIStateManager.State.FAILED else False,
|
||||
u'is_in_progress': True if uca.state == CourseRerunUIStateManager.State.IN_PROGRESS else False,
|
||||
u'is_failed': True if uca.state == CourseRerunUIStateManager.State.FAILED else False, # lint-amnesty, pylint: disable=simplifiable-if-expression
|
||||
u'is_in_progress': True if uca.state == CourseRerunUIStateManager.State.IN_PROGRESS else False, # lint-amnesty, pylint: disable=simplifiable-if-expression
|
||||
u'dismiss_link': reverse_course_url(
|
||||
u'course_notifications_handler',
|
||||
uca.course_key,
|
||||
@@ -679,7 +679,7 @@ def course_index(request, course_key):
|
||||
'lms_link': lms_link,
|
||||
'sections': sections,
|
||||
'course_structure': course_structure,
|
||||
'initial_state': course_outline_initial_state(locator_to_show, course_structure) if locator_to_show else None,
|
||||
'initial_state': course_outline_initial_state(locator_to_show, course_structure) if locator_to_show else None, # lint-amnesty, pylint: disable=line-too-long
|
||||
'rerun_notification_id': current_action.id if current_action else None,
|
||||
'course_release_date': course_release_date,
|
||||
'settings_url': settings_url,
|
||||
@@ -893,7 +893,7 @@ def create_new_course(user, org, number, run, fields):
|
||||
try:
|
||||
org_data = ensure_organization(org)
|
||||
except InvalidOrganizationException:
|
||||
raise ValidationError(_(
|
||||
raise ValidationError(_( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
'You must link this course to an organization in order to continue. Organization '
|
||||
'you selected does not exist in the system, you will need to add it to the system'
|
||||
))
|
||||
@@ -985,7 +985,7 @@ def course_info_handler(request, course_key_string):
|
||||
try:
|
||||
course_key = CourseKey.from_string(course_key_string)
|
||||
except InvalidKeyError:
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
with modulestore().bulk_operations(course_key):
|
||||
course_module = get_course_and_check_access(course_key, request.user)
|
||||
@@ -1041,7 +1041,7 @@ def course_info_update_handler(request, course_key_string, provided_id=None):
|
||||
elif request.method == 'DELETE':
|
||||
try:
|
||||
return JsonResponse(delete_course_update(usage_key, request.json, provided_id, request.user))
|
||||
except:
|
||||
except: # lint-amnesty, pylint: disable=bare-except
|
||||
return HttpResponseBadRequest(
|
||||
"Failed to delete",
|
||||
content_type="text/plain"
|
||||
@@ -1050,7 +1050,7 @@ def course_info_update_handler(request, course_key_string, provided_id=None):
|
||||
elif request.method in ('POST', 'PUT'):
|
||||
try:
|
||||
return JsonResponse(update_course_updates(usage_key, request.json, provided_id, request.user))
|
||||
except:
|
||||
except: # lint-amnesty, pylint: disable=bare-except
|
||||
return HttpResponseBadRequest(
|
||||
"Failed to save",
|
||||
content_type="text/plain"
|
||||
@@ -1061,7 +1061,7 @@ def course_info_update_handler(request, course_key_string, provided_id=None):
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(("GET", "PUT", "POST"))
|
||||
@expect_json
|
||||
def settings_handler(request, course_key_string):
|
||||
def settings_handler(request, course_key_string): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Course settings for dates and about pages
|
||||
GET
|
||||
@@ -1156,7 +1156,7 @@ def settings_handler(request, course_key_string):
|
||||
|
||||
# if 'minimum_grade_credit' of a course is not set or 0 then
|
||||
# show warning message to course author.
|
||||
show_min_grade_warning = False if course_module.minimum_grade_credit > 0 else True
|
||||
show_min_grade_warning = False if course_module.minimum_grade_credit > 0 else True # lint-amnesty, pylint: disable=simplifiable-if-expression
|
||||
settings_context.update(
|
||||
{
|
||||
'is_credit_course': True,
|
||||
@@ -1185,7 +1185,7 @@ def settings_handler(request, course_key_string):
|
||||
set_prerequisite_courses(course_key, prerequisite_course_keys)
|
||||
else:
|
||||
# None is chosen, so remove the course prerequisites
|
||||
course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires")
|
||||
course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires") # lint-amnesty, pylint: disable=line-too-long
|
||||
for milestone in course_milestones:
|
||||
remove_prerequisite_course(course_key, milestone)
|
||||
|
||||
@@ -1412,7 +1412,7 @@ def advanced_settings_handler(request, course_key_string):
|
||||
|
||||
class TextbookValidationError(Exception):
|
||||
"An error thrown when a textbook input is invalid"
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
def validate_textbooks_json(text):
|
||||
@@ -1424,7 +1424,7 @@ def validate_textbooks_json(text):
|
||||
try:
|
||||
textbooks = json.loads(text)
|
||||
except ValueError:
|
||||
raise TextbookValidationError("invalid JSON")
|
||||
raise TextbookValidationError("invalid JSON") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
if not isinstance(textbooks, (list, tuple)):
|
||||
raise TextbookValidationError("must be JSON list")
|
||||
for textbook in textbooks:
|
||||
@@ -1447,7 +1447,7 @@ def validate_textbook_json(textbook):
|
||||
try:
|
||||
textbook = json.loads(textbook)
|
||||
except ValueError:
|
||||
raise TextbookValidationError("invalid JSON")
|
||||
raise TextbookValidationError("invalid JSON") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
if not isinstance(textbook, dict):
|
||||
raise TextbookValidationError("must be JSON object")
|
||||
if not textbook.get("tab_title"):
|
||||
@@ -1768,7 +1768,7 @@ def group_configurations_detail_handler(request, course_key_string, group_config
|
||||
|
||||
if request.method in ('POST', 'PUT'): # can be either and sometimes django is rewriting one to the other
|
||||
try:
|
||||
new_configuration = GroupConfiguration(request.body, course, group_configuration_id).get_user_partition()
|
||||
new_configuration = GroupConfiguration(request.body, course, group_configuration_id).get_user_partition() # lint-amnesty, pylint: disable=line-too-long
|
||||
except GroupConfigurationsValidationError as err:
|
||||
return JsonResponse({"error": text_type(err)}, status=400)
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ def _get_entrance_exam(request, course_key):
|
||||
return HttpResponse(status=404)
|
||||
try:
|
||||
exam_descriptor = modulestore().get_item(exam_key)
|
||||
return HttpResponse(
|
||||
return HttpResponse( # lint-amnesty, pylint: disable=http-response-with-content-type-json
|
||||
dump_js_escaped_json({'locator': six.text_type(exam_descriptor.location)}),
|
||||
status=200, content_type='application/json')
|
||||
except ItemNotFoundError:
|
||||
@@ -235,7 +235,7 @@ def _delete_entrance_exam(request, course_key):
|
||||
return HttpResponse(status=204)
|
||||
|
||||
|
||||
def add_entrance_exam_milestone(course_id, x_block):
|
||||
def add_entrance_exam_milestone(course_id, x_block): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
# Add an entrance exam milestone if one does not already exist for given xBlock
|
||||
# As this is a standalone method for entrance exam, We should check that given xBlock should be an entrance exam.
|
||||
if x_block.is_entrance_exam:
|
||||
@@ -245,7 +245,7 @@ def add_entrance_exam_milestone(course_id, x_block):
|
||||
course_id
|
||||
)
|
||||
milestones = milestones_helpers.get_milestones(milestone_namespace)
|
||||
if len(milestones):
|
||||
if len(milestones): # lint-amnesty, pylint: disable=len-as-condition
|
||||
milestone = milestones[0]
|
||||
else:
|
||||
description = u'Autogenerated during {} entrance exam creation.'.format(six.text_type(course_id))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
import functools
|
||||
|
||||
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseServerError
|
||||
@@ -19,7 +20,7 @@ def jsonable_error(status=500, message="The Studio servers encountered an error"
|
||||
def inner(request, *args, **kwargs):
|
||||
if request.is_ajax():
|
||||
content = dump_js_escaped_json({"error": message})
|
||||
return HttpResponse(content, content_type="application/json",
|
||||
return HttpResponse(content, content_type="application/json", # lint-amnesty, pylint: disable=http-response-with-content-type-json
|
||||
status=status)
|
||||
else:
|
||||
return func(request, *args, **kwargs)
|
||||
@@ -28,7 +29,7 @@ def jsonable_error(status=500, message="The Studio servers encountered an error"
|
||||
|
||||
|
||||
@jsonable_error(404, "Resource not found")
|
||||
def not_found(request, exception):
|
||||
def not_found(request, exception): # lint-amnesty, pylint: disable=unused-argument
|
||||
return render_to_response('error.html', {'error': '404'})
|
||||
|
||||
|
||||
@@ -39,7 +40,7 @@ def server_error(request):
|
||||
|
||||
@fix_crum_request
|
||||
@jsonable_error(404, "Resource not found")
|
||||
def render_404(request, exception):
|
||||
def render_404(request, exception): # lint-amnesty, pylint: disable=unused-argument
|
||||
return HttpResponseNotFound(render_to_string('404.html', {}, request=request))
|
||||
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ class AssetNotFoundException(Exception):
|
||||
"""
|
||||
Raised when asset not found
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class AssetSizeTooLargeException(Exception):
|
||||
"""
|
||||
Raised when the size of an uploaded asset exceeds the maximum size limit.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
@@ -142,7 +142,7 @@ def xblock_type_display_name(xblock, default_display_name=None):
|
||||
return _('Unit')
|
||||
component_class = XBlock.load_class(category, select=settings.XBLOCK_SELECT_FUNCTION)
|
||||
if hasattr(component_class, 'display_name') and component_class.display_name.default:
|
||||
return _(component_class.display_name.default)
|
||||
return _(component_class.display_name.default) # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
else:
|
||||
return default_display_name
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""
|
||||
""" # lint-amnesty, pylint: disable=django-not-configured
|
||||
These views handle all actions in Studio related to import and exporting of
|
||||
courses
|
||||
"""
|
||||
@@ -83,7 +83,7 @@ def import_handler(request, course_key_string):
|
||||
raise PermissionDenied()
|
||||
|
||||
if 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json'):
|
||||
if request.method == 'GET':
|
||||
if request.method == 'GET': # lint-amnesty, pylint: disable=no-else-raise
|
||||
raise NotImplementedError('coming soon')
|
||||
else:
|
||||
return _write_chunk(request, courselike_key)
|
||||
@@ -181,7 +181,7 @@ def _write_chunk(request, courselike_key):
|
||||
elif size > int(content_range['stop']) and size == int(content_range['end']):
|
||||
return JsonResponse({'ImportStatus': 1})
|
||||
|
||||
with open(temp_filepath, mode) as temp_file: # pylint: disable=W6005
|
||||
with open(temp_filepath, mode) as temp_file:
|
||||
for chunk in request.FILES['course-data'].chunks():
|
||||
temp_file.write(chunk)
|
||||
|
||||
@@ -201,7 +201,7 @@ def _write_chunk(request, courselike_key):
|
||||
})
|
||||
|
||||
log.info(u"Course import %s: Upload complete", courselike_key)
|
||||
with open(temp_filepath, 'rb') as local_file: # pylint: disable=W6005
|
||||
with open(temp_filepath, 'rb') as local_file:
|
||||
django_file = File(local_file)
|
||||
storage_path = course_import_export_storage.save(u'olx_import/' + filename, django_file)
|
||||
import_olx.delay(
|
||||
@@ -437,7 +437,7 @@ def export_output_handler(request, course_key_string):
|
||||
tarball = course_import_export_storage.open(artifact.file.name)
|
||||
return send_tarball(tarball, artifact.file.storage.size(artifact.file.name))
|
||||
except UserTaskArtifact.DoesNotExist:
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
finally:
|
||||
if artifact:
|
||||
artifact.file.close()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Views for items (modules)."""
|
||||
|
||||
|
||||
import hashlib
|
||||
import hashlib # lint-amnesty, pylint: disable=unused-import
|
||||
import logging
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
@@ -10,7 +10,7 @@ from uuid import uuid4
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
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.http import Http404, HttpResponse, HttpResponseBadRequest
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -528,7 +528,7 @@ def _update_with_callback(xblock, user, old_metadata=None, old_content=None):
|
||||
return modulestore().update_item(xblock, user.id)
|
||||
|
||||
|
||||
def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None, nullout=None,
|
||||
def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None, nullout=None, # lint-amnesty, pylint: disable=too-many-statements
|
||||
grader_type=None, is_prereq=None, prereq_usage_key=None, prereq_min_score=None,
|
||||
prereq_min_completion=None, publish=None, fields=None):
|
||||
"""
|
||||
@@ -1124,7 +1124,7 @@ def _get_gating_info(course, xblock):
|
||||
return info
|
||||
|
||||
|
||||
def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=False, include_child_info=False,
|
||||
def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=False, include_child_info=False, # lint-amnesty, pylint: disable=too-many-statements
|
||||
course_outline=False, include_children_predicate=NEVER, parent_xblock=None, graders=None,
|
||||
user=None, course=None, is_concise=False):
|
||||
"""
|
||||
|
||||
@@ -18,8 +18,8 @@ class OrganizationListView(View):
|
||||
"""
|
||||
|
||||
@method_decorator(login_required)
|
||||
def get(self, request, *args, **kwargs):
|
||||
def get(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""Returns organization list as json."""
|
||||
organizations = get_organizations()
|
||||
org_names_list = [(org["short_name"]) for org in organizations]
|
||||
return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8')
|
||||
return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8') # lint-amnesty, pylint: disable=http-response-with-content-type-json
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
|
||||
import logging
|
||||
from functools import partial
|
||||
@@ -74,11 +74,11 @@ def preview_handler(request, usage_key_string, handler, suffix=''):
|
||||
|
||||
except NoSuchHandlerError:
|
||||
log.exception(u"XBlock %s attempted to access missing handler %r", instance, handler)
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
except NotFoundError:
|
||||
log.exception("Module indicating to user that request doesn't exist")
|
||||
raise Http404
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
except ProcessingError:
|
||||
log.warning("Module raised an error while processing AJAX request",
|
||||
@@ -121,7 +121,7 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method
|
||||
# (see https://openedx.atlassian.net/browse/TE-811)
|
||||
return [
|
||||
aside_type
|
||||
for aside_type in super(PreviewModuleSystem, self).applicable_aside_types(block)
|
||||
for aside_type in super(PreviewModuleSystem, self).applicable_aside_types(block) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
if aside_type != 'acid_aside'
|
||||
]
|
||||
|
||||
@@ -285,7 +285,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
|
||||
is_reorderable = _is_xblock_reorderable(xblock, context)
|
||||
selected_groups_label = get_visibility_partition_info(xblock)['selected_groups_label']
|
||||
if selected_groups_label:
|
||||
selected_groups_label = _(u'Access restricted to: {list_of_groups}').format(list_of_groups=selected_groups_label)
|
||||
selected_groups_label = _(u'Access restricted to: {list_of_groups}').format(list_of_groups=selected_groups_label) # lint-amnesty, pylint: disable=line-too-long
|
||||
course = modulestore().get_course(xblock.location.course_key)
|
||||
template_context = {
|
||||
'xblock_context': context,
|
||||
|
||||
@@ -10,7 +10,7 @@ def stringify(key):
|
||||
return repr(tuple(key))
|
||||
|
||||
|
||||
class SessionKeyValueStore(KeyValueStore):
|
||||
class SessionKeyValueStore(KeyValueStore): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def __init__(self, request):
|
||||
self._session = request.session
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ def tabs_handler(request, course_key_string):
|
||||
course_item = modulestore().get_course(course_key)
|
||||
|
||||
if 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json'):
|
||||
if request.method == 'GET':
|
||||
if request.method == 'GET': # lint-amnesty, pylint: disable=no-else-raise
|
||||
raise NotImplementedError('coming soon')
|
||||
else:
|
||||
if 'tabs' in request.json:
|
||||
|
||||
@@ -3,7 +3,7 @@ Tests access.py
|
||||
"""
|
||||
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.test import TestCase
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
|
||||
@@ -20,7 +20,7 @@ class RolesTest(TestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Test case setup """
|
||||
super(RolesTest, self).setUp()
|
||||
super(RolesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.global_admin = AdminFactory()
|
||||
self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo')
|
||||
|
||||
@@ -43,7 +43,7 @@ class AssetsTestCase(CourseTestCase):
|
||||
Parent class for all asset tests.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(AssetsTestCase, self).setUp()
|
||||
super(AssetsTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('assets_handler', self.course.id)
|
||||
|
||||
def upload_asset(self, name="asset-1", asset_type='text'):
|
||||
@@ -343,7 +343,7 @@ class UploadTestCase(AssetsTestCase):
|
||||
Unit tests for uploading a file
|
||||
"""
|
||||
def setUp(self):
|
||||
super(UploadTestCase, self).setUp()
|
||||
super(UploadTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('assets_handler', self.course.id)
|
||||
|
||||
def test_happy_path(self):
|
||||
@@ -378,7 +378,7 @@ class DownloadTestCase(AssetsTestCase):
|
||||
Unit tests for downloading a file.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(DownloadTestCase, self).setUp()
|
||||
super(DownloadTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('assets_handler', self.course.id)
|
||||
# First, upload something.
|
||||
self.asset_name = 'download_test'
|
||||
@@ -502,7 +502,7 @@ class DeleteAssetTestCase(AssetsTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Scaffolding """
|
||||
super(DeleteAssetTestCase, self).setUp()
|
||||
super(DeleteAssetTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('assets_handler', self.course.id)
|
||||
# First, upload something.
|
||||
self.asset_name = 'delete_test'
|
||||
|
||||
@@ -208,11 +208,11 @@ class CertificatesListHandlerTestCase(
|
||||
Test cases for certificates_list_handler.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
def setUp(self): # lint-amnesty, pylint: disable=arguments-differ
|
||||
"""
|
||||
Set up CertificatesListHandlerTestCase.
|
||||
"""
|
||||
super(CertificatesListHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker')
|
||||
super(CertificatesListHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker') # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.reset_urls()
|
||||
|
||||
def _url(self):
|
||||
@@ -437,7 +437,7 @@ class CertificatesDetailHandlerTestCase(
|
||||
"""
|
||||
Set up CertificatesDetailHandlerTestCase.
|
||||
"""
|
||||
super(CertificatesDetailHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker')
|
||||
super(CertificatesDetailHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker') # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.reset_urls()
|
||||
|
||||
def _url(self, cid=-1):
|
||||
|
||||
@@ -31,7 +31,7 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase):
|
||||
reorderable_child_view = 'reorderable_container_child_preview'
|
||||
|
||||
def setUp(self):
|
||||
super(ContainerPageTestCase, self).setUp()
|
||||
super(ContainerPageTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.vertical = self._create_item(self.sequential.location, 'vertical', 'Unit')
|
||||
self.html = self._create_item(self.vertical.location, "html", "HTML")
|
||||
self.child_container = self._create_item(self.vertical.location, 'split_test', 'Split Test')
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestCourseIndex(CourseTestCase):
|
||||
"""
|
||||
Add a course with odd characters in the fields
|
||||
"""
|
||||
super(TestCourseIndex, self).setUp()
|
||||
super(TestCourseIndex, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# had a problem where index showed course but has_access failed to retrieve it for non-staff
|
||||
self.odd_course = CourseFactory.create(
|
||||
org='test.org_1-2',
|
||||
@@ -75,7 +75,7 @@ class TestCourseIndex(CourseTestCase):
|
||||
self.assertEqual(len(library_tab), 1)
|
||||
|
||||
# Add a library:
|
||||
lib1 = LibraryFactory.create()
|
||||
lib1 = LibraryFactory.create() # lint-amnesty, pylint: disable=unused-variable
|
||||
|
||||
index_url = '/home/'
|
||||
index_response = self.client.get(index_url, {}, HTTP_ACCEPT='text/html')
|
||||
@@ -329,7 +329,7 @@ class TestCourseIndexArchived(CourseTestCase):
|
||||
"""
|
||||
Add courses with the end date set to various values
|
||||
"""
|
||||
super(TestCourseIndexArchived, self).setUp()
|
||||
super(TestCourseIndexArchived, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Base course has no end date (so is active)
|
||||
self.course.end = None
|
||||
@@ -426,7 +426,7 @@ class TestCourseOutline(CourseTestCase):
|
||||
"""
|
||||
Set up the for the course outline tests.
|
||||
"""
|
||||
super(TestCourseOutline, self).setUp()
|
||||
super(TestCourseOutline, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.chapter = ItemFactory.create(
|
||||
parent_location=self.course.location, category='chapter', display_name="Week 1"
|
||||
@@ -604,7 +604,7 @@ class TestCourseReIndex(CourseTestCase):
|
||||
Set up the for the course outline tests.
|
||||
"""
|
||||
|
||||
super(TestCourseReIndex, self).setUp()
|
||||
super(TestCourseReIndex, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course.start = datetime.datetime(2014, 1, 1, tzinfo=pytz.utc)
|
||||
modulestore().update_item(self.course, self.user.id)
|
||||
|
||||
@@ -5,8 +5,8 @@ unit tests for course_info views and models.
|
||||
|
||||
import json
|
||||
|
||||
from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
from django.test.utils import override_settings # lint-amnesty, pylint: disable=unused-import
|
||||
from mock import patch # lint-amnesty, pylint: disable=unused-import
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
|
||||
from cms.djangoapps.contentstore.tests.test_course_settings import CourseTestCase
|
||||
@@ -15,7 +15,7 @@ from openedx.core.lib.xblock_utils import get_course_update_items
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
class CourseUpdateTest(CourseTestCase):
|
||||
class CourseUpdateTest(CourseTestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
|
||||
def create_update_url(self, provided_id=None, course_key=None):
|
||||
if course_key is None:
|
||||
@@ -45,7 +45,7 @@ class CourseUpdateTest(CourseTestCase):
|
||||
)
|
||||
self.assertContains(resp, 'Course Updates', status_code=200)
|
||||
|
||||
init_content = '<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0">'
|
||||
init_content = '<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0">' # lint-amnesty, pylint: disable=line-too-long
|
||||
content = init_content + '</iframe>'
|
||||
payload = get_response(content, 'January 8, 2013')
|
||||
self.assertHTMLEqual(payload['content'], content)
|
||||
@@ -223,7 +223,7 @@ class CourseUpdateTest(CourseTestCase):
|
||||
course_updates.data = 'bad news'
|
||||
modulestore().update_item(course_updates, self.user.id)
|
||||
|
||||
init_content = '<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0">'
|
||||
init_content = '<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0">' # lint-amnesty, pylint: disable=line-too-long
|
||||
content = init_content + '</iframe>'
|
||||
payload = {'content': content, 'date': 'January 8, 2013'}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreditEligibilityTest(CourseTestCase):
|
||||
eligibility requirements.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(CreditEligibilityTest, self).setUp()
|
||||
super(CreditEligibilityTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(org='edX', number='dummy', display_name='Credit Course')
|
||||
self.course_details_url = reverse_course_url('settings_handler', six.text_type(self.course.id))
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import json
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.test.client import RequestFactory
|
||||
from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from mock import patch
|
||||
@@ -40,7 +40,7 @@ class EntranceExamHandlerTests(CourseTestCase, MilestonesTestCaseMixin):
|
||||
"""
|
||||
Shared scaffolding for individual test runs
|
||||
"""
|
||||
super(EntranceExamHandlerTests, self).setUp()
|
||||
super(EntranceExamHandlerTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_key = self.course.id
|
||||
self.usage_key = self.course.location
|
||||
self.course_url = '/course/{}'.format(six.text_type(self.course.id))
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestExamSettingsView(CourseTestCase, UrlResetMixin):
|
||||
"""
|
||||
Set up the for the exam settings view tests.
|
||||
"""
|
||||
super(TestExamSettingsView, self).setUp()
|
||||
super(TestExamSettingsView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.reset_urls()
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -30,7 +30,7 @@ class TestSubsectionGating(CourseTestCase):
|
||||
"""
|
||||
Initial data setup
|
||||
"""
|
||||
super(TestSubsectionGating, self).setUp()
|
||||
super(TestSubsectionGating, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Enable subsection gating for the test course
|
||||
self.course.enable_subsection_gating = True
|
||||
|
||||
@@ -267,7 +267,7 @@ class GroupConfigurationsListHandlerTestCase(CourseTestCase, GroupConfigurations
|
||||
|
||||
# This creates a random UserPartition.
|
||||
self.course.user_partitions = [
|
||||
UserPartition(0, 'First name', 'First description', [Group(0, 'Group A'), Group(1, 'Group B'), Group(2, 'Group C')]),
|
||||
UserPartition(0, 'First name', 'First description', [Group(0, 'Group A'), Group(1, 'Group B'), Group(2, 'Group C')]), # lint-amnesty, pylint: disable=line-too-long
|
||||
]
|
||||
self.save_course()
|
||||
|
||||
@@ -873,7 +873,7 @@ class GroupConfigurationsUsageInfoTestCase(CourseTestCase, HelperMethods):
|
||||
]
|
||||
self.store.update_item(self.course, ModuleStoreEnum.UserID.test)
|
||||
|
||||
__, split_test, problem = self._create_content_experiment(cid=0, name_suffix='0', group_id=3, cid_for_problem=1)
|
||||
__, split_test, problem = self._create_content_experiment(cid=0, name_suffix='0', group_id=3, cid_for_problem=1) # lint-amnesty, pylint: disable=unused-variable
|
||||
|
||||
expected = {
|
||||
'id': 1,
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestHeaderMenu(CourseTestCase, UrlResetMixin):
|
||||
"""
|
||||
Set up the for the course header menu tests.
|
||||
"""
|
||||
super(TestHeaderMenu, self).setUp()
|
||||
super(TestHeaderMenu, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.reset_urls()
|
||||
|
||||
def test_header_menu_without_web_certs_enabled(self):
|
||||
|
||||
@@ -57,7 +57,7 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(ImportEntranceExamTestCase, self).setUp()
|
||||
super(ImportEntranceExamTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('import_handler', self.course.id)
|
||||
self.content_dir = path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.content_dir)
|
||||
@@ -94,7 +94,7 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin):
|
||||
self.assertIsNotNone(course)
|
||||
self.assertEqual(course.entrance_exam_enabled, False)
|
||||
|
||||
with open(self.entrance_exam_tar, 'rb') as gtar: # pylint: disable=open-builtin
|
||||
with open(self.entrance_exam_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
args = {"name": self.entrance_exam_tar, "course-data": [gtar]}
|
||||
resp = self.client.post(self.url, args)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
@@ -126,7 +126,7 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin):
|
||||
self.assertTrue(len(content_milestones))
|
||||
|
||||
# Now import entrance exam course
|
||||
with open(self.entrance_exam_tar, 'rb') as gtar: # pylint: disable=open-builtin
|
||||
with open(self.entrance_exam_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
args = {"name": self.entrance_exam_tar, "course-data": [gtar]}
|
||||
resp = self.client.post(self.url, args)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
@@ -145,14 +145,14 @@ class ImportTestCase(CourseTestCase):
|
||||
CREATE_USER = True
|
||||
|
||||
def setUp(self):
|
||||
super(ImportTestCase, self).setUp()
|
||||
super(ImportTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('import_handler', self.course.id)
|
||||
self.content_dir = path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.content_dir)
|
||||
|
||||
def touch(name):
|
||||
""" Equivalent to shell's 'touch'"""
|
||||
with open(name, 'a'): # pylint: disable=W6005
|
||||
with open(name, 'a'):
|
||||
os.utime(name, None)
|
||||
|
||||
# Create tar test files -----------------------------------------------
|
||||
@@ -185,7 +185,7 @@ class ImportTestCase(CourseTestCase):
|
||||
Check that the response for a tar.gz import without a course.xml is
|
||||
correct.
|
||||
"""
|
||||
with open(self.bad_tar, 'rb') as btar: # pylint: disable=open-builtin
|
||||
with open(self.bad_tar, 'rb') as btar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
resp = self.client.post(
|
||||
self.url,
|
||||
{
|
||||
@@ -210,7 +210,7 @@ class ImportTestCase(CourseTestCase):
|
||||
Check that the response for a tar.gz import with a course.xml is
|
||||
correct.
|
||||
"""
|
||||
with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin
|
||||
with open(self.good_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
args = {"name": self.good_tar, "course-data": [gtar]}
|
||||
resp = self.client.post(self.url, args)
|
||||
|
||||
@@ -229,7 +229,7 @@ class ImportTestCase(CourseTestCase):
|
||||
display_name_before_import = course.display_name
|
||||
|
||||
# Check that global staff user can import course
|
||||
with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin
|
||||
with open(self.good_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
args = {"name": self.good_tar, "course-data": [gtar]}
|
||||
resp = self.client.post(self.url, args)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
@@ -247,7 +247,7 @@ class ImportTestCase(CourseTestCase):
|
||||
|
||||
# Now course staff user can also successfully import course
|
||||
self.client.login(username=nonstaff_user.username, password='foo')
|
||||
with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin
|
||||
with open(self.good_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
args = {"name": self.good_tar, "course-data": [gtar]}
|
||||
resp = self.client.post(self.url, args)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
@@ -341,7 +341,7 @@ class ImportTestCase(CourseTestCase):
|
||||
|
||||
def try_tar(tarpath):
|
||||
""" Attempt to tar an unacceptable file """
|
||||
with open(tarpath, 'rb') as tar: # pylint: disable=open-builtin
|
||||
with open(tarpath, 'rb') as tar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
args = {"name": tarpath, "course-data": [tar]}
|
||||
resp = self.client.post(self.url, args)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
@@ -501,7 +501,7 @@ class ImportTestCase(CourseTestCase):
|
||||
# Construct the modulestore for storing the import (using the previously created contentstore)
|
||||
with SPLIT_MODULESTORE_SETUP.build(contentstore=source_content) as source_store:
|
||||
# Use the test branch setting.
|
||||
with source_store.branch_setting(branch_setting):
|
||||
with source_store.branch_setting(branch_setting): # lint-amnesty, pylint: disable=no-member
|
||||
source_library_key = LibraryLocator(org='TestOrg', library='TestProbs')
|
||||
|
||||
extract_dir = path(tempfile.mkdtemp(dir=settings.DATA_DIR))
|
||||
@@ -538,7 +538,7 @@ class ExportTestCase(CourseTestCase):
|
||||
"""
|
||||
Sets up the test course.
|
||||
"""
|
||||
super(ExportTestCase, self).setUp()
|
||||
super(ExportTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.url = reverse_course_url('export_handler', self.course.id)
|
||||
self.status_url = reverse_course_url('export_status_handler', self.course.id)
|
||||
|
||||
@@ -854,7 +854,7 @@ class TestLibraryImportExport(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestLibraryImportExport, self).setUp()
|
||||
super(TestLibraryImportExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.export_dir = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, self.export_dir, ignore_errors=True)
|
||||
|
||||
@@ -912,7 +912,7 @@ class TestCourseExportImport(LibraryTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestCourseExportImport, self).setUp()
|
||||
super(TestCourseExportImport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.export_dir = tempfile.mkdtemp()
|
||||
|
||||
# Create a problem in library
|
||||
@@ -1035,7 +1035,7 @@ class TestCourseExportImportProblem(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestCourseExportImportProblem, self).setUp()
|
||||
super(TestCourseExportImportProblem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.export_dir = tempfile.mkdtemp()
|
||||
self.source_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
|
||||
self.addCleanup(shutil.rmtree, self.export_dir, ignore_errors=True)
|
||||
|
||||
@@ -89,7 +89,7 @@ class AsideTest(XBlockAside):
|
||||
class ItemTest(CourseTestCase):
|
||||
""" Base test class for create, save, and delete """
|
||||
def setUp(self):
|
||||
super(ItemTest, self).setUp()
|
||||
super(ItemTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course_key = self.course.id
|
||||
self.usage_key = self.course.location
|
||||
@@ -115,7 +115,7 @@ class ItemTest(CourseTestCase):
|
||||
key = key.map_into_course(CourseKey.from_string(parsed['courseKey']))
|
||||
return key
|
||||
|
||||
def create_xblock(self, parent_usage_key=None, display_name=None, category=None, boilerplate=None):
|
||||
def create_xblock(self, parent_usage_key=None, display_name=None, category=None, boilerplate=None): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
data = {
|
||||
'parent_locator': six.text_type(
|
||||
self.usage_key
|
||||
@@ -680,7 +680,7 @@ class TestDuplicateItem(ItemTest, DuplicateHelper):
|
||||
|
||||
def setUp(self):
|
||||
""" Creates the test course structure and a few components to 'duplicate'. """
|
||||
super(TestDuplicateItem, self).setUp()
|
||||
super(TestDuplicateItem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# Create a parent chapter (for testing children of children).
|
||||
resp = self.create_xblock(parent_usage_key=self.usage_key, category='chapter')
|
||||
self.chapter_usage_key = self.response_usage_key(resp)
|
||||
@@ -789,7 +789,7 @@ class TestMoveItem(ItemTest):
|
||||
"""
|
||||
Creates the test course structure to build course outline tree.
|
||||
"""
|
||||
super(TestMoveItem, self).setUp()
|
||||
super(TestMoveItem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.setup_course()
|
||||
|
||||
def setup_course(self, default_store=None):
|
||||
@@ -1208,7 +1208,7 @@ class TestMoveItem(ItemTest):
|
||||
self.course,
|
||||
course_id=self.course.id,
|
||||
)
|
||||
html.runtime._services['partitions'] = partitions_service
|
||||
html.runtime._services['partitions'] = partitions_service # lint-amnesty, pylint: disable=protected-access
|
||||
|
||||
# Set access settings so html will contradict vert2 when moved into that unit
|
||||
vert2.group_access = {self.course.user_partitions[0].id: [group1.id]}
|
||||
@@ -1341,7 +1341,7 @@ class TestDuplicateItemWithAsides(ItemTest, DuplicateHelper):
|
||||
|
||||
def setUp(self):
|
||||
""" Creates the test course structure and a few components to 'duplicate'. """
|
||||
super(TestDuplicateItemWithAsides, self).setUp()
|
||||
super(TestDuplicateItemWithAsides, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# Create a parent chapter
|
||||
resp = self.create_xblock(parent_usage_key=self.usage_key, category='chapter')
|
||||
self.chapter_usage_key = self.response_usage_key(resp)
|
||||
@@ -1402,7 +1402,7 @@ class TestEditItemSetup(ItemTest):
|
||||
|
||||
def setUp(self):
|
||||
""" Creates the test course structure and a couple problems to 'edit'. """
|
||||
super(TestEditItemSetup, self).setUp()
|
||||
super(TestEditItemSetup, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# create a chapter
|
||||
display_name = 'chapter created'
|
||||
resp = self.create_xblock(display_name=display_name, category='chapter')
|
||||
@@ -1768,7 +1768,7 @@ class TestEditItem(TestEditItemSetup):
|
||||
data={'publish': 'make_public'}
|
||||
)
|
||||
self._verify_published_with_no_draft(self.problem_usage_key)
|
||||
published = modulestore().get_item(self.problem_usage_key, revision=ModuleStoreEnum.RevisionOption.published_only)
|
||||
published = modulestore().get_item(self.problem_usage_key, revision=ModuleStoreEnum.RevisionOption.published_only) # lint-amnesty, pylint: disable=line-too-long
|
||||
|
||||
# Update the draft version and check that published is different.
|
||||
self.client.ajax_post(
|
||||
@@ -1924,7 +1924,7 @@ class TestEditSplitModule(ItemTest):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestEditSplitModule, self).setUp()
|
||||
super(TestEditSplitModule, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.user = UserFactory()
|
||||
|
||||
self.first_user_partition_group_1 = Group(six.text_type(MINIMUM_STATIC_PARTITION_ID + 1), 'alpha')
|
||||
@@ -2147,7 +2147,7 @@ class TestComponentHandler(TestCase):
|
||||
"""Tests for component handler api"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestComponentHandler, self).setUp()
|
||||
super(TestComponentHandler, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.request_factory = RequestFactory()
|
||||
|
||||
@@ -2179,7 +2179,7 @@ class TestComponentHandler(TestCase):
|
||||
@ddt.data('GET', 'POST', 'PUT', 'DELETE')
|
||||
def test_request_method(self, method):
|
||||
|
||||
def check_handler(handler, request, suffix):
|
||||
def check_handler(handler, request, suffix): # lint-amnesty, pylint: disable=unused-argument
|
||||
self.assertEqual(request.method, method)
|
||||
return Response()
|
||||
|
||||
@@ -2194,7 +2194,7 @@ class TestComponentHandler(TestCase):
|
||||
|
||||
@ddt.data(200, 404, 500)
|
||||
def test_response_code(self, status_code):
|
||||
def create_response(handler, request, suffix):
|
||||
def create_response(handler, request, suffix): # lint-amnesty, pylint: disable=unused-argument
|
||||
return Response(status_code=status_code)
|
||||
|
||||
self.descriptor.handle = create_response
|
||||
@@ -2208,7 +2208,7 @@ class TestComponentHandler(TestCase):
|
||||
"""
|
||||
test get_aside_from_xblock called
|
||||
"""
|
||||
def create_response(handler, request, suffix):
|
||||
def create_response(handler, request, suffix): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""create dummy response"""
|
||||
return Response(status_code=200)
|
||||
|
||||
@@ -2246,7 +2246,7 @@ class TestComponentTemplates(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestComponentTemplates, self).setUp()
|
||||
super(TestComponentTemplates, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# Advanced Module support levels.
|
||||
XBlockStudioConfiguration.objects.create(name='poll', enabled=True, support_level="fs")
|
||||
XBlockStudioConfiguration.objects.create(name='survey', enabled=True, support_level="ps")
|
||||
@@ -2508,7 +2508,7 @@ class TestXBlockInfo(ItemTest):
|
||||
Unit tests for XBlock's outline handling.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestXBlockInfo, self).setUp()
|
||||
super(TestXBlockInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
user_id = self.user.id
|
||||
self.chapter = ItemFactory.create(
|
||||
parent_location=self.course.location, category='chapter', display_name="Week 1", user_id=user_id,
|
||||
@@ -2953,7 +2953,7 @@ class TestLibraryXBlockInfo(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestLibraryXBlockInfo, self).setUp()
|
||||
super(TestLibraryXBlockInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
user_id = self.user.id
|
||||
self.library = LibraryFactory.create()
|
||||
self.top_level_html = ItemFactory.create(
|
||||
|
||||
@@ -44,7 +44,7 @@ class UnitTestLibraries(CourseTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(UnitTestLibraries, self).setUp()
|
||||
super(UnitTestLibraries, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.client = AjaxEnabledTestClient()
|
||||
self.client.login(username=self.user.username, password=self.user_password)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user