BOM-2282
Apply pylint-amnesty.
This commit is contained in:
@@ -11,10 +11,10 @@ import logging
|
||||
|
||||
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.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db.models import Count, Q
|
||||
from django.db.models import Count, Q # lint-amnesty, pylint: disable=unused-import
|
||||
from django.urls import reverse
|
||||
from edx_proctoring.api import get_exam_violation_report
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey
|
||||
@@ -426,7 +426,7 @@ def course_registration_features(features, registration_codes, csv_type):
|
||||
site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
|
||||
registration_features = [x for x in COURSE_REGISTRATION_FEATURES if x in features]
|
||||
|
||||
course_registration_dict = dict((feature, getattr(registration_code, feature)) for feature in registration_features)
|
||||
course_registration_dict = dict((feature, getattr(registration_code, feature)) for feature in registration_features) # lint-amnesty, pylint: disable=line-too-long
|
||||
course_registration_dict['company_name'] = None
|
||||
if registration_code.invoice_item:
|
||||
course_registration_dict['company_name'] = registration_code.invoice_item.invoice.company_name
|
||||
|
||||
@@ -52,7 +52,7 @@ class ProfileDistribution(object):
|
||||
|
||||
class ValidationError(ValueError):
|
||||
""" Error thrown if validation fails. """
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
def __init__(self, feature):
|
||||
self.feature = feature
|
||||
@@ -112,7 +112,7 @@ def profile_distribution(course_id, feature):
|
||||
|
||||
# short name and display name (full) of the choices.
|
||||
choices = [(short, full)
|
||||
for (short, full) in raw_choices] + [('no_data', 'No Data')]
|
||||
for (short, full) in raw_choices] + [('no_data', 'No Data')] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
|
||||
def get_filter(feature, value):
|
||||
""" Get the orm filter parameters for a feature. """
|
||||
@@ -130,7 +130,7 @@ def profile_distribution(course_id, feature):
|
||||
).count()
|
||||
|
||||
distribution = {}
|
||||
for (short, full) in choices:
|
||||
for (short, full) in choices: # lint-amnesty, pylint: disable=unused-variable
|
||||
# handle no data case
|
||||
if short == 'no_data':
|
||||
distribution['no_data'] = 0
|
||||
|
||||
@@ -5,23 +5,23 @@ Tests for instructor.basic
|
||||
|
||||
|
||||
import ddt
|
||||
import datetime
|
||||
import json
|
||||
import datetime # lint-amnesty, pylint: disable=unused-import, wrong-import-order
|
||||
import json # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
import pytz
|
||||
from django.db.models import Q
|
||||
from django.urls import reverse
|
||||
import pytz # lint-amnesty, pylint: disable=unused-import
|
||||
from django.db.models import Q # lint-amnesty, pylint: disable=unused-import
|
||||
from django.urls import reverse # lint-amnesty, pylint: disable=unused-import
|
||||
from edx_proctoring.api import create_exam
|
||||
from edx_proctoring.models import ProctoredExamStudentAttempt
|
||||
from mock import MagicMock, Mock, patch
|
||||
from opaque_keys.edx.locator import UsageKey
|
||||
from six import text_type
|
||||
from six import text_type # lint-amnesty, pylint: disable=unused-import
|
||||
from six.moves import range, zip
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
|
||||
from common.djangoapps.course_modes.models import CourseMode # lint-amnesty, pylint: disable=unused-import
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.courseware.tests.factories import InstructorFactory
|
||||
from lms.djangoapps.instructor_analytics.basic import (
|
||||
from lms.djangoapps.instructor_analytics.basic import ( # lint-amnesty, pylint: disable=unused-import
|
||||
AVAILABLE_FEATURES,
|
||||
PROFILE_FEATURES,
|
||||
STUDENT_FEATURES,
|
||||
@@ -36,7 +36,7 @@ from lms.djangoapps.instructor_analytics.basic import (
|
||||
)
|
||||
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
|
||||
from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed
|
||||
from common.djangoapps.student.roles import CourseSalesAdminRole
|
||||
from common.djangoapps.student.roles import CourseSalesAdminRole # lint-amnesty, pylint: disable=unused-import
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
@@ -47,7 +47,7 @@ class TestAnalyticsBasic(ModuleStoreTestCase):
|
||||
""" Test basic analytics functions. """
|
||||
|
||||
def setUp(self):
|
||||
super(TestAnalyticsBasic, self).setUp()
|
||||
super(TestAnalyticsBasic, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_key = self.store.make_course_key('robot', 'course', 'id')
|
||||
self.users = tuple(UserFactory() for _ in range(30))
|
||||
self.ces = tuple(CourseEnrollment.enroll(user, self.course_key)
|
||||
|
||||
@@ -105,7 +105,7 @@ class TestAnalyticsFormatInstances(TestCase):
|
||||
return 'dval'
|
||||
|
||||
def setUp(self):
|
||||
super(TestAnalyticsFormatInstances, self).setUp()
|
||||
super(TestAnalyticsFormatInstances, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.instances = [self.TestDataClass() for _ in range(5)]
|
||||
|
||||
def test_format_instances_response(self):
|
||||
|
||||
@@ -15,7 +15,7 @@ class TestAnalyticsDistributions(TestCase):
|
||||
'''Test analytics distribution gathering.'''
|
||||
|
||||
def setUp(self):
|
||||
super(TestAnalyticsDistributions, self).setUp()
|
||||
super(TestAnalyticsDistributions, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_id = CourseLocator('robot', 'course', 'id')
|
||||
|
||||
self.users = [UserFactory(
|
||||
@@ -78,7 +78,7 @@ class TestAnalyticsDistributionsNoData(TestCase):
|
||||
'''Test analytics distribution gathering.'''
|
||||
|
||||
def setUp(self):
|
||||
super(TestAnalyticsDistributionsNoData, self).setUp()
|
||||
super(TestAnalyticsDistributionsNoData, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_id = CourseLocator('robot', 'course', 'id')
|
||||
|
||||
self.users = [UserFactory(
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# pylint: disable=missing-module-docstring
|
||||
# lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring
|
||||
default_app_config = 'lms.djangoapps.instructor_task.apps.InstructorTaskConfig'
|
||||
|
||||
@@ -12,7 +12,7 @@ from .config.models import GradeReportSetting
|
||||
from .models import InstructorTask
|
||||
|
||||
|
||||
def mark_tasks_as_failed(modeladmin, request, queryset):
|
||||
def mark_tasks_as_failed(modeladmin, request, queryset): # lint-amnesty, pylint: disable=unused-argument
|
||||
queryset.update(
|
||||
task_state='FAILURE',
|
||||
task_output='{}',
|
||||
@@ -22,7 +22,7 @@ def mark_tasks_as_failed(modeladmin, request, queryset):
|
||||
mark_tasks_as_failed.short_description = "Mark Tasks as Failed"
|
||||
|
||||
|
||||
class InstructorTaskAdmin(admin.ModelAdmin):
|
||||
class InstructorTaskAdmin(admin.ModelAdmin): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
actions = [mark_tasks_as_failed]
|
||||
list_display = [
|
||||
'task_id',
|
||||
|
||||
@@ -51,7 +51,7 @@ class SpecificStudentIdMissingError(Exception):
|
||||
"""
|
||||
Exception indicating that a student id was not provided when generating a certificate for a specific student.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
def get_running_instructor_tasks(course_id):
|
||||
|
||||
@@ -35,7 +35,7 @@ class AlreadyRunningError(Exception):
|
||||
|
||||
if not message:
|
||||
message = self.message
|
||||
super(AlreadyRunningError, self).__init__(message)
|
||||
super(AlreadyRunningError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
|
||||
class QueueConnectionError(Exception):
|
||||
@@ -47,7 +47,7 @@ class QueueConnectionError(Exception):
|
||||
def __init__(self, message=None):
|
||||
if not message:
|
||||
message = self.message
|
||||
super(QueueConnectionError, self).__init__(message)
|
||||
super(QueueConnectionError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
|
||||
def _task_is_running(course_id, task_type, task_key):
|
||||
@@ -449,7 +449,7 @@ def submit_task(request, task_type, task_class, course_key, task_input, task_key
|
||||
try:
|
||||
task_class.apply_async(task_args, task_id=task_id)
|
||||
|
||||
except Exception as error:
|
||||
except Exception as error: # lint-amnesty, pylint: disable=broad-except
|
||||
_handle_instructor_task_failure(instructor_task, error)
|
||||
|
||||
return instructor_task
|
||||
|
||||
@@ -10,9 +10,9 @@ class UpdateProblemModuleStateError(Exception):
|
||||
Used when the current module cannot be processed and no more
|
||||
modules should be attempted.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class DuplicateTaskException(Exception):
|
||||
"""Exception indicating that a task already exists or has already completed."""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
@@ -96,7 +96,7 @@ class Command(BaseCommand):
|
||||
|
||||
for task in tasks:
|
||||
print(
|
||||
"{task_state} task '{task_id}', of type '{task_type}', created on '{created}', will be marked as 'FAILURE'".format(
|
||||
"{task_state} task '{task_id}', of type '{task_type}', created on '{created}', will be marked as 'FAILURE'".format( # lint-amnesty, pylint: disable=line-too-long
|
||||
task_state=task.task_state,
|
||||
task_id=task.task_id,
|
||||
task_type=task.task_type,
|
||||
|
||||
@@ -23,7 +23,7 @@ class TestFailOldQueueingTasksCommand(InstructorTaskTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestFailOldQueueingTasksCommand, self).setUp()
|
||||
super(TestFailOldQueueingTasksCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
type_1_queueing = InstructorTaskFactory.create(
|
||||
task_state=QUEUING,
|
||||
|
||||
@@ -25,7 +25,7 @@ from uuid import uuid4
|
||||
import six
|
||||
from boto.exception import BotoServerError
|
||||
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.files.base import ContentFile
|
||||
from django.db import models, transaction
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
@@ -49,7 +49,7 @@ def _get_number_of_subtasks(total_num_items, items_per_task):
|
||||
|
||||
|
||||
@contextmanager
|
||||
def track_memory_usage(metric, course_id):
|
||||
def track_memory_usage(metric, course_id): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""
|
||||
Context manager to track how much memory (in bytes) a given process uses.
|
||||
Metrics will look like: 'course_email.subtask_generation.memory.rss'
|
||||
@@ -63,11 +63,11 @@ def track_memory_usage(metric, course_id):
|
||||
for memory_type, baseline_usage in zip(memory_types, baseline_usages):
|
||||
total_memory_info = process.memory_info()
|
||||
total_usage = getattr(total_memory_info, memory_type)
|
||||
memory_used = total_usage - baseline_usage
|
||||
memory_used = total_usage - baseline_usage # lint-amnesty, pylint: disable=unused-variable
|
||||
|
||||
|
||||
def _generate_items_for_subtask(
|
||||
item_querysets, # pylint: disable=bad-continuation
|
||||
item_querysets, # lint-amnesty, pylint: disable=bad-continuation, bad-option-value
|
||||
item_fields,
|
||||
total_num_items,
|
||||
items_per_task,
|
||||
@@ -119,7 +119,7 @@ def _generate_items_for_subtask(
|
||||
# more items than items_per_task allows. We expect this to be a small enough
|
||||
# number as to be negligible.
|
||||
if num_items_queued != total_num_items:
|
||||
TASK_LOG.info(u"Number of items generated by chunking %s not equal to original total %s", num_items_queued, total_num_items)
|
||||
TASK_LOG.info(u"Number of items generated by chunking %s not equal to original total %s", num_items_queued, total_num_items) # lint-amnesty, pylint: disable=line-too-long
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
@@ -148,7 +148,7 @@ class SubtaskStatus(object):
|
||||
Also, we should count up "not attempted" separately from attempted/failed.
|
||||
"""
|
||||
|
||||
def __init__(self, task_id, attempted=None, succeeded=0, failed=0, skipped=0, retried_nomax=0, retried_withmax=0, state=None):
|
||||
def __init__(self, task_id, attempted=None, succeeded=0, failed=0, skipped=0, retried_nomax=0, retried_withmax=0, state=None): # lint-amnesty, pylint: disable=line-too-long
|
||||
"""Construct a SubtaskStatus object."""
|
||||
self.task_id = task_id
|
||||
if attempted is not None:
|
||||
@@ -273,7 +273,7 @@ def initialize_subtask_info(entry, action_name, total_num, subtask_id_list):
|
||||
return task_progress
|
||||
|
||||
|
||||
# pylint: disable=bad-continuation
|
||||
# lint-amnesty, pylint: disable=bad-continuation, bad-option-value
|
||||
def queue_subtasks_for_query(
|
||||
entry,
|
||||
action_name,
|
||||
@@ -421,7 +421,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
|
||||
subtask_dict = json.loads(entry.subtasks)
|
||||
subtask_status_info = subtask_dict['status']
|
||||
if current_task_id not in subtask_status_info:
|
||||
format_str = u"Unexpected task_id '{}': unable to find status for subtask of instructor task '{}': rejecting task {}"
|
||||
format_str = u"Unexpected task_id '{}': unable to find status for subtask of instructor task '{}': rejecting task {}" # lint-amnesty, pylint: disable=line-too-long
|
||||
msg = format_str.format(current_task_id, entry, new_subtask_status)
|
||||
TASK_LOG.warning(msg)
|
||||
raise DuplicateTaskException(msg)
|
||||
@@ -431,7 +431,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
|
||||
subtask_status = SubtaskStatus.from_dict(subtask_status_info[current_task_id])
|
||||
subtask_state = subtask_status.state
|
||||
if subtask_state in READY_STATES:
|
||||
format_str = u"Unexpected task_id '{}': already completed - status {} for subtask of instructor task '{}': rejecting task {}"
|
||||
format_str = u"Unexpected task_id '{}': already completed - status {} for subtask of instructor task '{}': rejecting task {}" # lint-amnesty, pylint: disable=line-too-long
|
||||
msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status)
|
||||
TASK_LOG.warning(msg)
|
||||
raise DuplicateTaskException(msg)
|
||||
@@ -444,7 +444,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status):
|
||||
new_retry_count = new_subtask_status.get_retry_count()
|
||||
current_retry_count = subtask_status.get_retry_count()
|
||||
if new_retry_count < current_retry_count:
|
||||
format_str = u"Unexpected task_id '{}': already retried - status {} for subtask of instructor task '{}': rejecting task {}"
|
||||
format_str = u"Unexpected task_id '{}': already retried - status {} for subtask of instructor task '{}': rejecting task {}" # lint-amnesty, pylint: disable=line-too-long
|
||||
msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status)
|
||||
TASK_LOG.warning(msg)
|
||||
raise DuplicateTaskException(msg)
|
||||
@@ -481,7 +481,7 @@ def update_subtask_status(entry_id, current_task_id, new_subtask_status, retry_c
|
||||
current_task_id, entry_id, new_subtask_status, retry_count)
|
||||
update_subtask_status(entry_id, current_task_id, new_subtask_status, retry_count)
|
||||
else:
|
||||
TASK_LOG.info(u"Failed to update status after %d retries for subtask %s of instructor task %d with status %s",
|
||||
TASK_LOG.info(u"Failed to update status after %d retries for subtask %s of instructor task %d with status %s", # lint-amnesty, pylint: disable=line-too-long
|
||||
retry_count, current_task_id, entry_id, new_subtask_status)
|
||||
raise
|
||||
finally:
|
||||
|
||||
@@ -24,7 +24,7 @@ import logging
|
||||
from functools import partial
|
||||
|
||||
from celery import shared_task
|
||||
from django.conf import settings
|
||||
from django.conf import settings # lint-amnesty, pylint: disable=unused-import
|
||||
from django.utils.translation import ugettext_noop
|
||||
from edx_django_utils.monitoring import set_code_owner_attribute
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from lms.djangoapps.instructor_task.models import InstructorTask
|
||||
TASK_LOG = logging.getLogger('edx.celery.task')
|
||||
|
||||
|
||||
class BaseInstructorTask(Task):
|
||||
class BaseInstructorTask(Task): # lint-amnesty, pylint: disable=abstract-method
|
||||
"""
|
||||
Base task class for use with InstructorTask models.
|
||||
|
||||
@@ -30,7 +30,7 @@ class BaseInstructorTask(Task):
|
||||
"""
|
||||
abstract = True
|
||||
|
||||
def on_success(self, task_progress, task_id, args, kwargs):
|
||||
def on_success(self, task_progress, task_id, args, kwargs): # lint-amnesty, pylint: disable=arguments-differ
|
||||
"""
|
||||
Update InstructorTask object corresponding to this task with info about success.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Instructor tasks related to certificates.
|
||||
|
||||
from time import time
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.db.models import Q
|
||||
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
|
||||
@@ -7,21 +7,21 @@ import logging
|
||||
from datetime import datetime
|
||||
from time import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings # lint-amnesty, pylint: disable=unused-import
|
||||
from django.utils.translation import ugettext as _ # lint-amnesty, pylint: disable=unused-import
|
||||
from pytz import UTC
|
||||
from six import StringIO
|
||||
from six import StringIO # lint-amnesty, pylint: disable=unused-import
|
||||
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_string
|
||||
from lms.djangoapps.courseware.courses import get_course_by_id
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_string # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.courseware.courses import get_course_by_id # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.instructor_analytics.basic import enrolled_students_features, list_may_enroll
|
||||
from lms.djangoapps.instructor_analytics.csvs import format_dictlist
|
||||
from lms.djangoapps.instructor_task.models import ReportStore
|
||||
from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment
|
||||
from common.djangoapps.util.file import course_filename_prefix_generator
|
||||
from lms.djangoapps.instructor_task.models import ReportStore # lint-amnesty, pylint: disable=unused-import
|
||||
from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment # lint-amnesty, pylint: disable=unused-import
|
||||
from common.djangoapps.util.file import course_filename_prefix_generator # lint-amnesty, pylint: disable=unused-import
|
||||
|
||||
from .runner import TaskProgress
|
||||
from .utils import tracker_emit, upload_csv_to_report_store
|
||||
from .utils import tracker_emit, upload_csv_to_report_store # lint-amnesty, pylint: disable=unused-import
|
||||
|
||||
TASK_LOG = logging.getLogger('edx.celery.task')
|
||||
FILTERED_OUT_ROLES = ['staff', 'instructor', 'finance_admin', 'sales_admin']
|
||||
|
||||
@@ -11,13 +11,13 @@ from time import time
|
||||
import re
|
||||
import six
|
||||
from lms.djangoapps.course_blocks.api import get_course_blocks
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from lazy import lazy
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
from pytz import UTC
|
||||
from six import text_type
|
||||
from six.moves import zip, zip_longest
|
||||
from django.conf import settings # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from django.contrib.auth import get_user_model # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from lazy import lazy # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from opaque_keys.edx.keys import UsageKey # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from pytz import UTC # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from six import text_type # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from six.moves import zip, zip_longest # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from lms.djangoapps.certificates.models import CertificateWhitelist, GeneratedCertificate, certificate_info_for_user
|
||||
@@ -371,7 +371,7 @@ class _CertificateBulkContext(object):
|
||||
}
|
||||
|
||||
|
||||
class _TeamBulkContext(object):
|
||||
class _TeamBulkContext(object): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def __init__(self, context, users):
|
||||
self.enabled = context.teams_enabled
|
||||
if self.enabled:
|
||||
@@ -390,7 +390,7 @@ class _EnrollmentBulkContext(object):
|
||||
self.verified_users = set(IDVerificationService.get_verified_user_ids(users))
|
||||
|
||||
|
||||
class _CourseGradeBulkContext(object):
|
||||
class _CourseGradeBulkContext(object): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def __init__(self, context, users):
|
||||
self.certs = _CertificateBulkContext(context, users)
|
||||
self.teams = _TeamBulkContext(context, users)
|
||||
@@ -415,7 +415,7 @@ class CourseGradeReport(object):
|
||||
"""
|
||||
with modulestore().bulk_operations(course_id):
|
||||
context = _CourseGradeReportContext(_xmodule_instance_args, _entry_id, course_id, _task_input, action_name)
|
||||
return CourseGradeReport()._generate(context)
|
||||
return CourseGradeReport()._generate(context) # lint-amnesty, pylint: disable=protected-access
|
||||
|
||||
def _generate(self, context):
|
||||
"""
|
||||
@@ -604,7 +604,7 @@ class CourseGradeReport(object):
|
||||
subsection_grades.append(subsection_grade)
|
||||
return subsection_grades, grade_results
|
||||
|
||||
def _user_assignment_average(self, course_grade, subsection_grades, assignment_info):
|
||||
def _user_assignment_average(self, course_grade, subsection_grades, assignment_info): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if assignment_info['separate_subsection_avg_headers']:
|
||||
if assignment_info['grader']:
|
||||
if course_grade.attempted:
|
||||
@@ -902,7 +902,7 @@ class ProblemResponses(object):
|
||||
student_data_keys = OrderedDict()
|
||||
|
||||
with store.bulk_operations(course_key):
|
||||
for usage_key in usage_keys:
|
||||
for usage_key in usage_keys: # lint-amnesty, pylint: disable=too-many-nested-blocks
|
||||
if max_count is not None and max_count <= 0:
|
||||
break
|
||||
course_blocks = get_course_blocks(user, usage_key)
|
||||
|
||||
@@ -9,16 +9,16 @@ import logging
|
||||
from collections import OrderedDict
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime
|
||||
from io import StringIO
|
||||
from io import StringIO # lint-amnesty, pylint: disable=unused-import
|
||||
from tempfile import TemporaryFile
|
||||
from time import time
|
||||
from zipfile import ZipFile
|
||||
from zipfile import ZipFile # lint-amnesty, pylint: disable=unused-import
|
||||
import csv
|
||||
import os
|
||||
import os # lint-amnesty, pylint: disable=unused-import
|
||||
import unicodecsv
|
||||
import six
|
||||
|
||||
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 ValidationError
|
||||
from django.core.files.storage import DefaultStorage
|
||||
from openassessment.data import OraAggregateData, OraDownloadData
|
||||
@@ -172,7 +172,7 @@ def _get_csv_file_content(csv_file):
|
||||
return UniversalNewlineIterator(csv_content)
|
||||
|
||||
|
||||
def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, task_input, action_name):
|
||||
def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Within a given course, cohort students in bulk, then upload the results
|
||||
using a `ReportStore`.
|
||||
@@ -240,7 +240,7 @@ def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, tas
|
||||
try:
|
||||
# If add_user_to_cohort successfully adds a user, a user object is returned.
|
||||
# If a user is preassigned to a cohort, no user object is returned (we already have the email address).
|
||||
(user, previous_cohort, preassigned) = add_user_to_cohort(cohorts_status[cohort_name]['cohort'], username_or_email)
|
||||
(user, previous_cohort, preassigned) = add_user_to_cohort(cohorts_status[cohort_name]['cohort'], username_or_email) # lint-amnesty, pylint: disable=line-too-long, unused-variable
|
||||
if preassigned:
|
||||
cohorts_status[cohort_name]['Preassigned Learners'].add(username_or_email)
|
||||
task_progress.preassigned += 1
|
||||
@@ -268,10 +268,10 @@ def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, tas
|
||||
task_progress.update_task_state(extra_meta=current_step)
|
||||
|
||||
# Filter the output of `add_users_to_cohorts` in order to upload the result.
|
||||
output_header = ['Cohort Name', 'Exists', 'Learners Added', 'Learners Not Found', 'Invalid Email Addresses', 'Preassigned Learners']
|
||||
output_header = ['Cohort Name', 'Exists', 'Learners Added', 'Learners Not Found', 'Invalid Email Addresses', 'Preassigned Learners'] # lint-amnesty, pylint: disable=line-too-long
|
||||
output_rows = [
|
||||
[
|
||||
','.join(status_dict.get(column_name, '')) if (column_name == 'Learners Not Found'
|
||||
','.join(status_dict.get(column_name, '')) if (column_name == 'Learners Not Found' # lint-amnesty, pylint: disable=consider-using-in
|
||||
or column_name == 'Invalid Email Addresses'
|
||||
or column_name == 'Preassigned Learners')
|
||||
else status_dict[column_name]
|
||||
@@ -322,7 +322,7 @@ def upload_ora2_data(
|
||||
|
||||
try:
|
||||
header, datarows = OraAggregateData.collect_ora2_data(course_id)
|
||||
rows = [header] + [row for row in datarows]
|
||||
rows = [header] + [row for row in datarows] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
# Update progress to failed regardless of error type
|
||||
except Exception: # pylint: disable=broad-except
|
||||
TASK_LOG.exception('Failed to get ORA data.')
|
||||
@@ -444,7 +444,7 @@ def upload_ora2_submission_files(
|
||||
'Failed to upload zip file to storage.',
|
||||
'Error while uploading zip file to storage',
|
||||
):
|
||||
zip_filename = upload_zip_to_report_store(zip_file, 'submission_files', course_id, start_date),
|
||||
zip_filename = upload_zip_to_report_store(zip_file, 'submission_files', course_id, start_date), # lint-amnesty, pylint: disable=trailing-comma-tuple
|
||||
|
||||
if not zip_filename:
|
||||
return UPDATE_STATUS_FAILED
|
||||
|
||||
@@ -241,7 +241,7 @@ def override_score_module_state(xmodule_instance_args, module_descriptor, studen
|
||||
raise UpdateProblemModuleStateError(msg)
|
||||
|
||||
weighted_override_score = float(task_input['score'])
|
||||
if not (0 <= weighted_override_score <= instance.max_score()):
|
||||
if not (0 <= weighted_override_score <= instance.max_score()): # lint-amnesty, pylint: disable=superfluous-parens
|
||||
msg = "Score must be between 0 and the maximum points available for the problem."
|
||||
raise UpdateProblemModuleStateError(msg)
|
||||
|
||||
@@ -252,7 +252,7 @@ def override_score_module_state(xmodule_instance_args, module_descriptor, studen
|
||||
set_event_transaction_type(grades_events.GRADES_OVERRIDE_EVENT_TYPE)
|
||||
|
||||
problem_weight = instance.weight if instance.weight is not None else 1
|
||||
if problem_weight == 0:
|
||||
if problem_weight == 0: # lint-amnesty, pylint: disable=no-else-raise
|
||||
msg = "Scores cannot be overridden for a problem that has a weight of zero."
|
||||
raise UpdateProblemModuleStateError(msg)
|
||||
else:
|
||||
|
||||
@@ -14,7 +14,7 @@ from lms.djangoapps.instructor_task.models import InstructorTask
|
||||
from common.djangoapps.student.tests.factories import UserFactory as StudentUserFactory
|
||||
|
||||
|
||||
class InstructorTaskFactory(DjangoModelFactory):
|
||||
class InstructorTaskFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
class Meta(object):
|
||||
model = InstructorTask
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
|
||||
"""Tests API methods that involve the submission of module-based background tasks."""
|
||||
|
||||
def setUp(self):
|
||||
super(InstructorTaskModuleSubmitTest, self).setUp()
|
||||
super(InstructorTaskModuleSubmitTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.initialize_course()
|
||||
self.student = UserFactory.create(username="student", email="student@edx.org")
|
||||
@@ -189,12 +189,12 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
|
||||
task_function(self.create_task_request(self.instructor), location, **params)
|
||||
|
||||
|
||||
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
|
||||
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
|
||||
class InstructorTaskCourseSubmitTest(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
"""Tests API methods that involve the submission of course-based background tasks."""
|
||||
|
||||
def setUp(self):
|
||||
super(InstructorTaskCourseSubmitTest, self).setUp()
|
||||
super(InstructorTaskCourseSubmitTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.initialize_course()
|
||||
self.student = UserFactory.create(username="student", email="student@edx.org")
|
||||
|
||||
@@ -14,7 +14,7 @@ from uuid import uuid4
|
||||
import six
|
||||
import unicodecsv
|
||||
from celery.states import FAILURE, SUCCESS
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.urls import reverse
|
||||
from mock import Mock, patch
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
@@ -55,7 +55,7 @@ class InstructorTaskTestCase(CacheIsolationTestCase):
|
||||
Tests API and view methods that involve the reporting of status for background tasks.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(InstructorTaskTestCase, self).setUp()
|
||||
super(InstructorTaskTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.student = UserFactory.create(username="student", email="student@edx.org")
|
||||
self.instructor = UserFactory.create(username="instructor", email="instructor@edx.org")
|
||||
@@ -314,7 +314,7 @@ class TestReportMixin(object):
|
||||
if os.path.exists(self.tmp_dir):
|
||||
shutil.rmtree(self.tmp_dir)
|
||||
|
||||
super(TestReportMixin, self).setUp()
|
||||
super(TestReportMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Ensure that working with the temp directories in tests is thread safe
|
||||
# by creating a unique temporary directory for each testcase.
|
||||
@@ -356,7 +356,7 @@ class TestReportMixin(object):
|
||||
report_path = report_store.path_to(self.course.id, report_csv_filename)
|
||||
with report_store.storage.open(report_path) as csv_file:
|
||||
# Expand the dict reader generator so we don't lose it's content
|
||||
csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')]
|
||||
csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
|
||||
if ignore_other_columns:
|
||||
csv_rows = [
|
||||
|
||||
@@ -15,7 +15,7 @@ from collections import namedtuple
|
||||
import ddt
|
||||
import six
|
||||
from celery.states import FAILURE, SUCCESS
|
||||
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 django.urls import reverse
|
||||
from mock import patch
|
||||
@@ -61,7 +61,7 @@ class TestIntegrationTask(InstructorTaskModuleTestCase):
|
||||
self.assertEqual(instructor_task.task_type, task_type)
|
||||
task_input = json.loads(instructor_task.task_input)
|
||||
self.assertNotIn('student', task_input)
|
||||
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name)))
|
||||
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) # lint-amnesty, pylint: disable=line-too-long
|
||||
status = json.loads(instructor_task.task_output)
|
||||
self.assertEqual(status['exception'], 'ZeroDivisionError')
|
||||
self.assertEqual(status['message'], expected_message)
|
||||
@@ -80,7 +80,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestRescoringTask, self).setUp()
|
||||
super(TestRescoringTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.initialize_course()
|
||||
self.create_instructor('instructor')
|
||||
@@ -305,7 +305,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
self.assertEqual(instructor_task.task_type, 'rescore_problem')
|
||||
task_input = json.loads(instructor_task.task_input)
|
||||
self.assertNotIn('student', task_input)
|
||||
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name)))
|
||||
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) # lint-amnesty, pylint: disable=line-too-long
|
||||
status = json.loads(instructor_task.task_output)
|
||||
self.assertEqual(status['attempted'], 1)
|
||||
self.assertEqual(status['succeeded'], 0)
|
||||
@@ -370,7 +370,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
InstructorTaskModuleTestCase.problem_location(problem_url_name)
|
||||
)
|
||||
descriptor.data = problem_xml
|
||||
with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, descriptor.location.course_key):
|
||||
with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, descriptor.location.course_key): # lint-amnesty, pylint: disable=line-too-long
|
||||
self.module_store.update_item(descriptor, self.user.id)
|
||||
self.module_store.publish(descriptor.location, self.user.id)
|
||||
else:
|
||||
@@ -444,7 +444,7 @@ class TestResetAttemptsTask(TestIntegrationTask):
|
||||
userlist = ['u1', 'u2', 'u3', 'u4']
|
||||
|
||||
def setUp(self):
|
||||
super(TestResetAttemptsTask, self).setUp()
|
||||
super(TestResetAttemptsTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.initialize_course()
|
||||
self.create_instructor('instructor')
|
||||
for username in self.userlist:
|
||||
@@ -513,7 +513,7 @@ class TestDeleteProblemTask(TestIntegrationTask):
|
||||
userlist = ['u1', 'u2', 'u3', 'u4']
|
||||
|
||||
def setUp(self):
|
||||
super(TestDeleteProblemTask, self).setUp()
|
||||
super(TestDeleteProblemTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.initialize_course()
|
||||
self.create_instructor('instructor')
|
||||
@@ -598,7 +598,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent,
|
||||
Arguments:
|
||||
dicts: tuple of dicts
|
||||
"""
|
||||
return dict([item for d in dicts for item in d.items()])
|
||||
return dict([item for d in dicts for item in d.items()]) # lint-amnesty, pylint: disable=consider-using-dict-comprehension
|
||||
|
||||
def user_partition_group(user):
|
||||
"""Return a dict having single key with value equals to students group in partition"""
|
||||
|
||||
@@ -41,21 +41,21 @@ class ReportStoreTestMixin(object):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(ReportStoreTestMixin, self).setUp()
|
||||
super(ReportStoreTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course_id = CourseLocator(org="testx", course="coursex", run="runx")
|
||||
|
||||
def create_report_store(self):
|
||||
"""
|
||||
Subclasses should override this and return their report store.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
def test_links_for_order(self):
|
||||
"""
|
||||
Test that ReportStore.links_for() returns file download links
|
||||
in reverse chronological order.
|
||||
"""
|
||||
report_store = self.create_report_store()
|
||||
report_store = self.create_report_store() # lint-amnesty, pylint: disable=assignment-from-no-return
|
||||
self.assertEqual(report_store.links_for(self.course_id), [])
|
||||
|
||||
report_store.store(self.course_id, 'old_file', StringIO())
|
||||
|
||||
@@ -18,10 +18,10 @@ class TestSubtasks(InstructorTaskCourseTestCase):
|
||||
"""Tests for subtasks."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestSubtasks, self).setUp()
|
||||
super(TestSubtasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.initialize_course()
|
||||
|
||||
def _enroll_students_in_course(self, course_id, num_students):
|
||||
def _enroll_students_in_course(self, course_id, num_students): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""Create and enroll some students in the course."""
|
||||
|
||||
for _ in range(num_students):
|
||||
|
||||
@@ -7,7 +7,7 @@ paths actually work.
|
||||
|
||||
|
||||
import json
|
||||
from functools import partial
|
||||
from functools import partial # lint-amnesty, pylint: disable=unused-import
|
||||
from uuid import uuid4
|
||||
|
||||
import ddt
|
||||
@@ -31,7 +31,7 @@ from lms.djangoapps.instructor_task.tasks import (
|
||||
rescore_problem,
|
||||
reset_problem_attempts
|
||||
)
|
||||
from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data
|
||||
from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
|
||||
from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskModuleTestCase
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
@@ -43,7 +43,7 @@ class TestTaskFailure(Exception):
|
||||
"""
|
||||
An example exception to indicate failure of a mocked task.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class TestInstructorTasks(InstructorTaskModuleTestCase):
|
||||
@@ -52,7 +52,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestInstructorTasks, self).setUp()
|
||||
super(TestInstructorTasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.initialize_course()
|
||||
self.instructor = self.create_instructor('instructor')
|
||||
self.location = self.problem_location(PROBLEM_URL_NAME)
|
||||
@@ -94,7 +94,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
|
||||
|
||||
def _run_task_with_mock_celery(self, task_class, entry_id, task_id, expected_failure_message=None):
|
||||
"""Submit a task and mock how celery provides a current_task."""
|
||||
self.current_task = Mock()
|
||||
self.current_task = Mock() # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
self.current_task.request = Mock()
|
||||
self.current_task.request.id = task_id
|
||||
self.current_task.update_state = Mock()
|
||||
@@ -335,7 +335,7 @@ class TestOverrideScoreInstructorTask(TestInstructorTasks):
|
||||
Tests score override for a problem in a course, for all students succeeds.
|
||||
"""
|
||||
mock_instance = MagicMock()
|
||||
getattr(mock_instance, 'override_problem_score').return_value = None
|
||||
getattr(mock_instance, 'override_problem_score').return_value = None # lint-amnesty, pylint: disable=literal-used-as-attribute
|
||||
|
||||
num_students = 10
|
||||
self._create_students_with_state(num_students)
|
||||
@@ -428,7 +428,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
|
||||
mock_instance = MagicMock()
|
||||
del mock_instance.rescore_problem
|
||||
del mock_instance.rescore
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal') as mock_get_module:
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal') as mock_get_module: # lint-amnesty, pylint: disable=line-too-long
|
||||
mock_get_module.return_value = mock_instance
|
||||
with self.assertRaises(UpdateProblemModuleStateError):
|
||||
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
|
||||
@@ -451,7 +451,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
|
||||
num_students = 1
|
||||
self._create_students_with_state(num_students, input_state)
|
||||
task_entry = self._create_input_entry()
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal', return_value=None):
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal', return_value=None): # lint-amnesty, pylint: disable=line-too-long
|
||||
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
|
||||
|
||||
self.assert_task_output(
|
||||
@@ -469,7 +469,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
|
||||
Tests rescores a problem in a course, for all students succeeds.
|
||||
"""
|
||||
mock_instance = MagicMock()
|
||||
getattr(mock_instance, 'rescore').return_value = None
|
||||
getattr(mock_instance, 'rescore').return_value = None # lint-amnesty, pylint: disable=literal-used-as-attribute
|
||||
mock_instance.has_submitted_answer.return_value = True
|
||||
del mock_instance.done # old CAPA code used to use this value so we delete it here to be sure
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@ import tempfile
|
||||
from collections import OrderedDict
|
||||
from contextlib import contextmanager, ExitStack
|
||||
from datetime import datetime, timedelta
|
||||
from io import BytesIO
|
||||
from zipfile import ZipFile
|
||||
from io import BytesIO # lint-amnesty, pylint: disable=unused-import
|
||||
from zipfile import ZipFile # lint-amnesty, pylint: disable=unused-import
|
||||
|
||||
import ddt
|
||||
import unicodecsv
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse # lint-amnesty, pylint: disable=unused-import
|
||||
from edx_django_utils.cache import RequestCache
|
||||
from freezegun import freeze_time
|
||||
from mock import ANY, MagicMock, Mock, patch
|
||||
@@ -30,16 +30,16 @@ from pytz import UTC
|
||||
from six import text_type
|
||||
from six.moves import range, zip
|
||||
from six.moves.urllib.parse import quote
|
||||
from waffle.testutils import override_switch
|
||||
from waffle.testutils import override_switch # lint-amnesty, pylint: disable=unused-import
|
||||
|
||||
import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.courseware.models import StudentModule
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.courseware.tests.factories import InstructorFactory
|
||||
from lms.djangoapps.courseware.tests.factories import InstructorFactory # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.grades.course_data import CourseData
|
||||
from lms.djangoapps.grades.models import PersistentCourseGrade, PersistentSubsectionGradeOverride
|
||||
from lms.djangoapps.grades.subsection_grade import CreateSubsectionGrade
|
||||
@@ -76,7 +76,7 @@ from openedx.core.djangoapps.credit.tests.factories import CreditCourseFactory
|
||||
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
|
||||
from openedx.core.djangoapps.util.testing import ContentGroupTestCase, TestConditionalContent
|
||||
from openedx.core.lib.teams_config import TeamsConfig
|
||||
from common.djangoapps.student.models import ALLOWEDTOENROLL_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAllowed, ManualEnrollmentAudit
|
||||
from common.djangoapps.student.models import ALLOWEDTOENROLL_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAllowed, ManualEnrollmentAudit # lint-amnesty, pylint: disable=line-too-long, unused-import
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from lms.djangoapps.survey.models import SurveyAnswer, SurveyForm
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
@@ -121,7 +121,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
|
||||
Tests that CSV grade report generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestInstructorGradeReport, self).setUp()
|
||||
super(TestInstructorGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
@ddt.data([u'student@example.com', u'ni\xf1o@example.com'])
|
||||
@@ -445,7 +445,7 @@ class TestTeamGradeReport(InstructorGradeReportTestCase):
|
||||
""" Test that teams appear correctly in the grade report when it is enabled for the course. """
|
||||
|
||||
def setUp(self):
|
||||
super(TestTeamGradeReport, self).setUp()
|
||||
super(TestTeamGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG)
|
||||
self.student1 = UserFactory.create()
|
||||
CourseEnrollment.enroll(self.student1, self.course.id)
|
||||
@@ -485,7 +485,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestProblemResponsesReport, self).setUp()
|
||||
super(TestProblemResponsesReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.initialize_course()
|
||||
self.instructor = self.create_instructor('instructor')
|
||||
self.student = self.create_student('student')
|
||||
@@ -811,7 +811,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
Test that the problem CSV generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestProblemGradeReport, self).setUp()
|
||||
super(TestProblemGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.initialize_course()
|
||||
# Add unicode data to CSV even though unicode usernames aren't
|
||||
# technically possible in openedx.
|
||||
@@ -959,7 +959,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent,
|
||||
OPTION_2 = 'Option 2'
|
||||
|
||||
def setUp(self):
|
||||
super(TestProblemReportSplitTestContent, self).setUp()
|
||||
super(TestProblemReportSplitTestContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.problem_a_url = u'problem_a_url'
|
||||
self.problem_b_url = u'problem_b_url'
|
||||
self.define_option_problem(self.problem_a_url, parent=self.vertical_a)
|
||||
@@ -1088,7 +1088,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In
|
||||
Test the problem report on a course that has cohorted content.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestProblemReportCohortedContent, self).setUp()
|
||||
super(TestProblemReportCohortedContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
# construct cohorted problems to work on.
|
||||
self.add_course_content()
|
||||
vertical = ItemFactory.create(
|
||||
@@ -1184,7 +1184,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
Tests that Course Survey report generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestCourseSurveyReport, self).setUp()
|
||||
super(TestCourseSurveyReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
self.question1 = "question1"
|
||||
@@ -1279,7 +1279,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
Tests that CSV student profile report generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestStudentReport, self).setUp()
|
||||
super(TestStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
def test_success(self):
|
||||
@@ -1323,7 +1323,7 @@ class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
"Test the student report when including teams information. "
|
||||
|
||||
def setUp(self):
|
||||
super(TestTeamStudentReport, self).setUp()
|
||||
super(TestTeamStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG)
|
||||
self.student1 = UserFactory.create()
|
||||
CourseEnrollment.enroll(self.student1, self.course.id)
|
||||
@@ -1393,7 +1393,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestListMayEnroll, self).setUp()
|
||||
super(TestListMayEnroll, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
def test_success(self):
|
||||
@@ -1431,7 +1431,7 @@ class MockDefaultStorage(object):
|
||||
|
||||
def open(self, file_name):
|
||||
"""Mock out DefaultStorage.open with standard python open"""
|
||||
return open(file_name) # pylint: disable=open-builtin
|
||||
return open(file_name) # lint-amnesty, pylint: disable=bad-option-value, open-builtin
|
||||
|
||||
|
||||
@patch('lms.djangoapps.instructor_task.tasks_helper.misc.DefaultStorage', new=MockDefaultStorage)
|
||||
@@ -1440,7 +1440,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
Tests that bulk student cohorting works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestCohortStudents, self).setUp()
|
||||
super(TestCohortStudents, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
self.cohort_1 = CohortFactory(course_id=self.course.id, name='Cohort 1')
|
||||
@@ -1699,7 +1699,7 @@ class TestGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
Test that grade report has correct grade values.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestGradeReport, self).setUp()
|
||||
super(TestGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.create_course()
|
||||
self.student = self.create_student(u'üser_1')
|
||||
|
||||
@@ -1858,7 +1858,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
|
||||
Test that grade report has correct user enrollment, verification, and certificate information.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestGradeReportEnrollmentAndCertificateInfo, self).setUp()
|
||||
super(TestGradeReportEnrollmentAndCertificateInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
today = datetime.now(UTC)
|
||||
course_factory_kwargs = {
|
||||
@@ -2010,7 +2010,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
|
||||
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']
|
||||
|
||||
def setUp(self):
|
||||
super(TestCertificateGeneration, self).setUp()
|
||||
super(TestCertificateGeneration, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.initialize_course()
|
||||
|
||||
def test_certificate_generation_for_students(self):
|
||||
@@ -2569,13 +2569,13 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase):
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(TestInstructorOra2Report, self).setUp()
|
||||
super(TestInstructorOra2Report, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.current_task = Mock()
|
||||
self.current_task.update_state = Mock()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestInstructorOra2Report, self).tearDown()
|
||||
super(TestInstructorOra2Report, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
if os.path.exists(settings.GRADES_DOWNLOAD['ROOT_PATH']):
|
||||
shutil.rmtree(settings.GRADES_DOWNLOAD['ROOT_PATH'])
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
|
||||
import json
|
||||
import logging
|
||||
@@ -13,7 +13,7 @@ from lms.djangoapps.instructor_task.models import PROGRESS
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# return status for completed tasks and tasks in progress
|
||||
STATES_WITH_STATUS = [state for state in READY_STATES] + [PROGRESS]
|
||||
STATES_WITH_STATUS = [state for state in READY_STATES] + [PROGRESS] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
|
||||
|
||||
def _get_instructor_task_status(task_id):
|
||||
@@ -84,10 +84,10 @@ def instructor_task_status(request):
|
||||
if task_output is not None:
|
||||
output[task_id] = task_output
|
||||
|
||||
return HttpResponse(json.dumps(output, indent=4))
|
||||
return HttpResponse(json.dumps(output, indent=4)) # lint-amnesty, pylint: disable=http-response-with-json-dumps
|
||||
|
||||
|
||||
def get_task_completion_info(instructor_task):
|
||||
def get_task_completion_info(instructor_task): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Construct progress message from progress information in InstructorTask entry.
|
||||
|
||||
@@ -125,7 +125,7 @@ def get_task_completion_info(instructor_task):
|
||||
log.warning(fmt.format(instructor_task.task_id, instructor_task.task_output))
|
||||
return (succeeded, _("No progress status information available"))
|
||||
|
||||
action_name = _(task_output['action_name'])
|
||||
action_name = _(task_output['action_name']) # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
num_attempted = task_output['attempted']
|
||||
num_total = task_output['total']
|
||||
|
||||
@@ -152,19 +152,19 @@ def get_task_completion_info(instructor_task):
|
||||
|
||||
if instructor_task.task_state == PROGRESS:
|
||||
# special message for providing progress updates:
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {attempted} and {succeeded} are counts.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {attempted} and {succeeded} are counts. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Progress: {action} {succeeded} of {attempted} so far")
|
||||
elif student is not None and problem_url is not None:
|
||||
# this reports on actions on problems for a particular student:
|
||||
if num_attempted == 0:
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Unable to find submission to be {action} for student '{student}'")
|
||||
elif num_succeeded == 0:
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Problem failed to be {action} for student '{student}'")
|
||||
else:
|
||||
succeeded = True
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Problem successfully {action} for student '{student}'")
|
||||
elif student is not None and entrance_exam_url is not None:
|
||||
# this reports on actions on entrance exam for a particular student:
|
||||
@@ -190,7 +190,7 @@ def get_task_completion_info(instructor_task):
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {attempted} is a count.
|
||||
msg_format = _(u"Problem successfully {action} for {attempted} students")
|
||||
else: # num_succeeded < num_attempted
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Problem {action} for {succeeded} of {attempted} students")
|
||||
elif email_id is not None:
|
||||
# this reports on actions on bulk emails
|
||||
@@ -205,11 +205,11 @@ def get_task_completion_info(instructor_task):
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {attempted} is a count.
|
||||
msg_format = _(u"Message successfully {action} for {attempted} recipients")
|
||||
else: # num_succeeded < num_attempted
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Message {action} for {succeeded} of {attempted} recipients")
|
||||
else:
|
||||
# provide a default:
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts.
|
||||
# Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long
|
||||
msg_format = _(u"Status: {action} {succeeded} of {attempted}")
|
||||
|
||||
if num_skipped > 0:
|
||||
|
||||
@@ -8,7 +8,7 @@ import json
|
||||
from django.http import Http404
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import get_language_bidi, ugettext_lazy as _
|
||||
from django.utils.translation import get_language_bidi, ugettext_lazy as _ # lint-amnesty, pylint: disable=unused-import
|
||||
from web_fragments.fragment import Fragment
|
||||
|
||||
from lms.djangoapps.commerce.utils import EcommerceService
|
||||
@@ -71,7 +71,7 @@ class ProgramDetailsFragmentView(EdxFragmentView):
|
||||
Render the program details fragment.
|
||||
"""
|
||||
|
||||
def render_to_fragment(self, request, program_uuid, **kwargs):
|
||||
def render_to_fragment(self, request, program_uuid, **kwargs): # lint-amnesty, pylint: disable=arguments-differ
|
||||
"""View details about a specific program."""
|
||||
programs_config = kwargs.get('programs_config') or ProgramsApiConfig.current()
|
||||
if not programs_config.enabled or not request.user.is_authenticated:
|
||||
|
||||
@@ -60,7 +60,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase):
|
||||
super(TestProgramListing, cls).setUpClass()
|
||||
|
||||
cls.course = ModuleStoreCourseFactory()
|
||||
course_run = CourseRunFactory(key=six.text_type(cls.course.id))
|
||||
course_run = CourseRunFactory(key=six.text_type(cls.course.id)) # lint-amnesty, pylint: disable=no-member
|
||||
course = CourseFactory(course_runs=[course_run])
|
||||
|
||||
cls.first_program = ProgramFactory(courses=[course])
|
||||
@@ -69,7 +69,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase):
|
||||
cls.data = sorted([cls.first_program, cls.second_program], key=cls.program_sort_key)
|
||||
|
||||
def setUp(self):
|
||||
super(TestProgramListing, self).setUp()
|
||||
super(TestProgramListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory()
|
||||
self.client.login(username=self.user.username, password=self.password)
|
||||
@@ -140,7 +140,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase):
|
||||
self.create_programs_config()
|
||||
mock_get_programs.return_value = self.data
|
||||
|
||||
CourseEnrollmentFactory(user=self.user, course_id=self.course.id)
|
||||
CourseEnrollmentFactory(user=self.user, course_id=self.course.id) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
response = self.client.get(self.url)
|
||||
actual = load_serialized_data(response, 'programsData')
|
||||
@@ -181,7 +181,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase):
|
||||
self.create_programs_config()
|
||||
mock_get_programs.return_value = self.data
|
||||
|
||||
CourseEnrollmentFactory(user=self.user, course_id=self.course.id)
|
||||
CourseEnrollmentFactory(user=self.user, course_id=self.course.id) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
response = self.client.get(self.url)
|
||||
actual = load_serialized_data(response, 'programsData')
|
||||
@@ -208,17 +208,17 @@ class TestProgramDetails(ProgramsApiConfigMixin, CatalogIntegrationMixin, Shared
|
||||
super(TestProgramDetails, cls).setUpClass()
|
||||
|
||||
modulestore_course = ModuleStoreCourseFactory()
|
||||
course_run = CourseRunFactory(key=six.text_type(modulestore_course.id))
|
||||
course_run = CourseRunFactory(key=six.text_type(modulestore_course.id)) # lint-amnesty, pylint: disable=no-member
|
||||
course = CourseFactory(course_runs=[course_run])
|
||||
|
||||
cls.program_data = ProgramFactory(uuid=cls.program_uuid, courses=[course])
|
||||
cls.pathway_data = PathwayFactory()
|
||||
cls.program_data['pathway_ids'] = [cls.pathway_data['id']]
|
||||
cls.pathway_data['program_uuids'] = [cls.program_data['uuid']]
|
||||
del cls.pathway_data['programs']
|
||||
del cls.pathway_data['programs'] # lint-amnesty, pylint: disable=unsupported-delete-operation
|
||||
|
||||
def setUp(self):
|
||||
super(TestProgramDetails, self).setUp()
|
||||
super(TestProgramDetails, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory()
|
||||
self.client.login(username=self.user.username, password=self.password)
|
||||
|
||||
Reference in New Issue
Block a user