MICROBA-918 Fix warnings (#26397)
This commit is contained in:
@@ -5,15 +5,15 @@ Instructor tasks related to certificates.
|
||||
|
||||
from time import time
|
||||
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models import Q
|
||||
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from .runner import TaskProgress
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
def generate_students_certificates(
|
||||
@@ -65,7 +65,7 @@ def generate_students_certificates(
|
||||
# Mark existing generated certificates as 'unavailable' before regenerating
|
||||
# We need to call this method after "students_require_certificate" otherwise "students_require_certificate"
|
||||
# would return no results.
|
||||
invalidate_generated_certificates(course_id, students_to_generate_certs_for, statuses_to_regenerate)
|
||||
_invalidate_generated_certificates(course_id, students_to_generate_certs_for, statuses_to_regenerate)
|
||||
|
||||
task_progress.skipped = task_progress.total - len(students_require_certs)
|
||||
|
||||
@@ -122,7 +122,7 @@ def students_require_certificate(course_id, enrolled_students, statuses_to_regen
|
||||
return list(set(enrolled_students) - set(students_already_have_certs))
|
||||
|
||||
|
||||
def invalidate_generated_certificates(course_id, enrolled_students, certificate_statuses):
|
||||
def _invalidate_generated_certificates(course_id, enrolled_students, certificate_statuses):
|
||||
"""
|
||||
Invalidate generated certificates for all enrolled students in the given course having status in
|
||||
'certificate_statuses'.
|
||||
|
||||
@@ -15,14 +15,12 @@ import tempfile
|
||||
from collections import OrderedDict
|
||||
from contextlib import contextmanager, ExitStack
|
||||
from datetime import datetime, timedelta
|
||||
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 capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
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 +28,21 @@ 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 # lint-amnesty, pylint: disable=unused-import
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
|
||||
from xmodule.partitions.partitions import Group, UserPartition
|
||||
|
||||
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 # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.courseware.models import StudentModule
|
||||
from common.djangoapps.student.models import (
|
||||
CourseEnrollment,
|
||||
CourseEnrollmentAllowed
|
||||
)
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
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 # lint-amnesty, pylint: disable=unused-import
|
||||
from lms.djangoapps.courseware.models import StudentModule
|
||||
from lms.djangoapps.grades.course_data import CourseData
|
||||
from lms.djangoapps.grades.models import PersistentCourseGrade, PersistentSubsectionGradeOverride
|
||||
from lms.djangoapps.grades.subsection_grade import CreateSubsectionGrade
|
||||
@@ -68,6 +71,7 @@ from lms.djangoapps.instructor_task.tests.test_base import (
|
||||
InstructorTaskModuleTestCase,
|
||||
TestReportMixin
|
||||
)
|
||||
from lms.djangoapps.survey.models import SurveyAnswer, SurveyForm
|
||||
from lms.djangoapps.teams.tests.factories import CourseTeamFactory, CourseTeamMembershipFactory
|
||||
from lms.djangoapps.verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory
|
||||
from openedx.core.djangoapps.course_groups.models import CohortMembership, CourseUserGroupPartitionGroup
|
||||
@@ -76,14 +80,6 @@ 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 # 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
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
|
||||
from xmodule.partitions.partitions import Group, UserPartition
|
||||
|
||||
from ..models import ReportStore
|
||||
from ..tasks_helper.utils import UPDATE_STATUS_FAILED, UPDATE_STATUS_SUCCEEDED
|
||||
|
||||
@@ -121,7 +117,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
|
||||
Tests that CSV grade report generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestInstructorGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
@ddt.data([u'student@example.com', u'ni\xf1o@example.com'])
|
||||
@@ -344,7 +340,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
|
||||
"N" in the report.
|
||||
|
||||
Also confirms that a persisted passing grade will result in a Certificate Eligibility
|
||||
of "Y" incase of verified learners and "N" incase of audit laerners.
|
||||
of "Y" for verified learners and "N" for audit learners.
|
||||
"""
|
||||
course = CourseFactory.create()
|
||||
audit_user = CourseEnrollment.enroll(UserFactory.create(), course.id)
|
||||
@@ -445,7 +441,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() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG)
|
||||
self.student1 = UserFactory.create()
|
||||
CourseEnrollment.enroll(self.student1, self.course.id)
|
||||
@@ -485,7 +481,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestProblemResponsesReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.initialize_course()
|
||||
self.instructor = self.create_instructor('instructor')
|
||||
self.student = self.create_student('student')
|
||||
@@ -811,7 +807,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
Test that the problem CSV generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestProblemGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.initialize_course()
|
||||
# Add unicode data to CSV even though unicode usernames aren't
|
||||
# technically possible in openedx.
|
||||
@@ -959,7 +955,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent,
|
||||
OPTION_2 = 'Option 2'
|
||||
|
||||
def setUp(self):
|
||||
super(TestProblemReportSplitTestContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
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 +1084,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In
|
||||
Test the problem report on a course that has cohorted content.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestProblemReportCohortedContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
# construct cohorted problems to work on.
|
||||
self.add_course_content()
|
||||
vertical = ItemFactory.create(
|
||||
@@ -1184,7 +1180,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
Tests that Course Survey report generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestCourseSurveyReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
self.question1 = "question1"
|
||||
@@ -1279,7 +1275,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
Tests that CSV student profile report generation works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
def test_success(self):
|
||||
@@ -1320,10 +1316,12 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
|
||||
|
||||
class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
"Test the student report when including teams information. "
|
||||
"""
|
||||
Test the student report when including teams information.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestTeamStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG)
|
||||
self.student1 = UserFactory.create()
|
||||
CourseEnrollment.enroll(self.student1, self.course.id)
|
||||
@@ -1387,13 +1385,15 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
for it yet) works.
|
||||
"""
|
||||
def _create_enrollment(self, email):
|
||||
"Factory method for creating CourseEnrollmentAllowed objects."
|
||||
"""
|
||||
Factory method for creating CourseEnrollmentAllowed objects.
|
||||
"""
|
||||
return CourseEnrollmentAllowed.objects.create(
|
||||
email=email, course_id=self.course.id
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestListMayEnroll, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
def test_success(self):
|
||||
@@ -1440,7 +1440,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
Tests that bulk student cohorting works.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestCohortStudents, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
self.cohort_1 = CohortFactory(course_id=self.course.id, name='Cohort 1')
|
||||
@@ -1585,7 +1585,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
|
||||
def test_too_few_commas(self):
|
||||
"""
|
||||
A CSV file may be malformed and lack traling commas at the end of a row.
|
||||
A CSV file may be malformed and lack trailing commas at the end of a row.
|
||||
In this case, those cells take on the value None by the CSV parser.
|
||||
Make sure we handle None values appropriately.
|
||||
|
||||
@@ -1699,7 +1699,7 @@ class TestGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
Test that grade report has correct grade values.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
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() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
|
||||
today = datetime.now(UTC)
|
||||
course_factory_kwargs = {
|
||||
@@ -1899,7 +1899,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
|
||||
|
||||
def user_is_embargoed(self, user, is_embargoed):
|
||||
"""
|
||||
Set a users emabargo state.
|
||||
Set a users embargoed state.
|
||||
"""
|
||||
user_profile = UserFactory(username=user.username, email=user.email).profile
|
||||
user_profile.allow_certificate = not is_embargoed
|
||||
@@ -2010,7 +2010,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
|
||||
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']
|
||||
|
||||
def setUp(self):
|
||||
super(TestCertificateGeneration, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.initialize_course()
|
||||
|
||||
def test_certificate_generation_for_students(self):
|
||||
@@ -2498,7 +2498,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
|
||||
mode='honor'
|
||||
)
|
||||
|
||||
# mark 7th students to have certificates generated with status 'norpassing'
|
||||
# mark 7th students to have certificates generated with status 'notpassing'
|
||||
for student in students[6:7]:
|
||||
GeneratedCertificateFactory.create(
|
||||
user=student,
|
||||
@@ -2569,13 +2569,13 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase):
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(TestInstructorOra2Report, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
|
||||
self.current_task = Mock()
|
||||
self.current_task.update_state = Mock()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestInstructorOra2Report, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().tearDown()
|
||||
if os.path.exists(settings.GRADES_DOWNLOAD['ROOT_PATH']):
|
||||
shutil.rmtree(settings.GRADES_DOWNLOAD['ROOT_PATH'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user