Fix lint-amnesty warnings (#26411)

This commit is contained in:
Christie Rice
2021-02-08 10:49:32 -05:00
committed by GitHub
parent 1dca1835ce
commit 367d2a07c9
14 changed files with 116 additions and 97 deletions

View File

@@ -3,8 +3,6 @@ Tests for the Certificate REST APIs.
"""
from itertools import product # lint-amnesty, pylint: disable=unused-import
import ddt
import six
from django.conf import settings
@@ -14,17 +12,17 @@ from freezegun import freeze_time
from mock import patch
from rest_framework import status
from rest_framework.test import APITestCase
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.certificates.apis.v0.views import CertificatesDetailView, CertificatesListView
from lms.djangoapps.certificates.models import CertificateStatuses
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
from openedx.core.djangoapps.user_api.tests.factories import UserPreferenceFactory
from openedx.core.djangoapps.user_authn.tests.utils import JWT_AUTH_TYPES, AuthAndScopesTestMixin, AuthType
from common.djangoapps.student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt
@@ -56,7 +54,7 @@ class CertificatesDetailRestApiTest(AuthAndScopesTestMixin, SharedModuleStoreTes
freezer.start()
self.addCleanup(freezer.stop)
super(CertificatesDetailRestApiTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.cert = GeneratedCertificateFactory.create(
user=self.student,
@@ -159,7 +157,7 @@ class CertificatesListRestApiTest(AuthAndScopesTestMixin, SharedModuleStoreTestC
freezer.start()
self.addCleanup(freezer.stop)
super(CertificatesListRestApiTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.cert = GeneratedCertificateFactory.create(
user=self.student,

View File

@@ -1,10 +1,13 @@
# Factories are self documenting # lint-amnesty, pylint: disable=missing-module-docstring
"""
Certificates factories
"""
from uuid import uuid4
from factory.django import DjangoModelFactory
from common.djangoapps.student.models import LinkedInAddToProfileConfiguration
from lms.djangoapps.certificates.models import (
CertificateHtmlViewConfiguration,
CertificateInvalidation,
@@ -12,11 +15,12 @@ from lms.djangoapps.certificates.models import (
CertificateWhitelist,
GeneratedCertificate
)
from common.djangoapps.student.models import LinkedInAddToProfileConfiguration
class GeneratedCertificateFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class GeneratedCertificateFactory(DjangoModelFactory):
"""
GeneratedCertificate factory
"""
class Meta(object):
model = GeneratedCertificate
@@ -28,7 +32,10 @@ class GeneratedCertificateFactory(DjangoModelFactory): # lint-amnesty, pylint:
grade = ''
class CertificateWhitelistFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class CertificateWhitelistFactory(DjangoModelFactory):
"""
CertificateWhitelist factory
"""
class Meta(object):
model = CertificateWhitelist
@@ -38,7 +45,10 @@ class CertificateWhitelistFactory(DjangoModelFactory): # lint-amnesty, pylint:
notes = 'Test Notes'
class CertificateInvalidationFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class CertificateInvalidationFactory(DjangoModelFactory):
"""
CertificateInvalidation factory
"""
class Meta(object):
model = CertificateInvalidation
@@ -47,7 +57,10 @@ class CertificateInvalidationFactory(DjangoModelFactory): # lint-amnesty, pylin
active = True
class CertificateHtmlViewConfigurationFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class CertificateHtmlViewConfigurationFactory(DjangoModelFactory):
"""
CertificateHtmlViewConfiguration factory
"""
class Meta(object):
model = CertificateHtmlViewConfiguration
@@ -81,7 +94,10 @@ class CertificateHtmlViewConfigurationFactory(DjangoModelFactory): # lint-amnes
}"""
class LinkedInAddToProfileConfigurationFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class LinkedInAddToProfileConfigurationFactory(DjangoModelFactory):
"""
LinkedInAddToProfileConfiguration factory
"""
class Meta(object):
model = LinkedInAddToProfileConfiguration

View File

@@ -103,7 +103,7 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(CertificateDownloadableStatusTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.student = UserFactory()
self.student_no_cert = UserFactory()
@@ -643,7 +643,7 @@ class CertificateGenerationEnabledTest(EventTestMixin, TestCase):
COURSE_KEY = CourseLocator(org='test', course='test', run='test')
def setUp(self): # pylint: disable=arguments-differ
super(CertificateGenerationEnabledTest, self).setUp('lms.djangoapps.certificates.api.tracker') # lint-amnesty, pylint: disable=super-with-arguments
super().setUp('lms.djangoapps.certificates.api.tracker')
# Since model-based configuration is cached, we need
# to clear the cache before each test.

View File

@@ -30,7 +30,7 @@ class CertificateManagementTest(ModuleStoreTestCase):
command = 'resubmit_error_certificates'
def setUp(self):
super(CertificateManagementTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.user = UserFactory.create()
self.courses = [
CourseFactory.create()
@@ -161,7 +161,7 @@ class RegenerateCertificatesTest(CertificateManagementTest):
"""
We just need one course here.
"""
super(RegenerateCertificatesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = self.courses[0]
@ddt.data(True, False)
@@ -230,7 +230,7 @@ class UngenerateCertificatesTest(CertificateManagementTest):
"""
We just need one course here.
"""
super(UngenerateCertificatesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = self.courses[0]
@override_settings(CERT_QUEUE='test-queue')

View File

@@ -8,8 +8,8 @@ from django.test import TestCase
from opaque_keys.edx.locator import CourseLocator
from six import text_type
from lms.djangoapps.certificates.models import GeneratedCertificate
from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.certificates.models import GeneratedCertificate
class CreateFakeCertTest(TestCase):
@@ -18,7 +18,7 @@ class CreateFakeCertTest(TestCase):
COURSE_KEY = CourseLocator(org='edX', course='DemoX', run='Demo_Course')
def setUp(self):
super(CreateFakeCertTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.user = UserFactory.create(username=self.USERNAME)
def test_create_fake_cert(self):

View File

@@ -12,7 +12,10 @@ from django.test.utils import override_settings
from mock import patch
from opaque_keys.edx.locator import CourseKey, CourseLocator
from path import Path as path
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from common.djangoapps.student.tests.factories import AdminFactory, UserFactory
from lms.djangoapps.certificates.models import (
CertificateGenerationHistory,
CertificateHtmlViewConfiguration,
@@ -26,9 +29,6 @@ from lms.djangoapps.certificates.models import (
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
from common.djangoapps.student.tests.factories import AdminFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
FEATURES_INVALID_FILE_PATH = settings.FEATURES.copy()
FEATURES_INVALID_FILE_PATH['CERTS_HTML_VIEW_CONFIG_PATH'] = 'invalid/path/to/config.json'
@@ -50,7 +50,7 @@ class ExampleCertificateTest(TestCase):
ERROR_REASON = 'Kaboom!'
def setUp(self):
super(ExampleCertificateTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.cert_set = ExampleCertificateSet.objects.create(course_key=self.COURSE_KEY)
self.cert = ExampleCertificate.objects.create(
example_cert_set=self.cert_set,
@@ -109,7 +109,7 @@ class CertificateHtmlViewConfigurationTest(TestCase):
Test the CertificateHtmlViewConfiguration model.
"""
def setUp(self):
super(CertificateHtmlViewConfigurationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.configuration_string = """{
"default": {
"url": "http://www.edx.org",
@@ -204,7 +204,7 @@ class EligibleCertificateManagerTest(SharedModuleStoreTestCase):
"""
def setUp(self):
super(EligibleCertificateManagerTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.user = UserFactory()
self.course1 = CourseOverviewFactory()
@@ -319,10 +319,10 @@ class CertificateInvalidationTest(SharedModuleStoreTestCase):
"""
def setUp(self):
super(CertificateInvalidationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory()
self.user = UserFactory()
self.course_id = self.course.id # lint-amnesty, pylint: disable=no-member
self.course_id = self.course.id # pylint: disable=no-member
self.certificate = GeneratedCertificateFactory.create(
status=CertificateStatuses.downloadable,
user=self.user,

View File

@@ -10,20 +10,23 @@ import ddt
import freezegun
import pytz
import six
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from mock import Mock, patch
from opaque_keys.edx.locator import CourseLocator
from testfixtures import LogCapture
# It is really unfortunate that we are using the XQueue client
# code from the capa library. In the future, we should move this
# into a shared library. We import it here so we can mock it
# and verify that items are being correctly added to the queue
# in our `XQueueCertInterface` implementation.
from capa.xqueue_interface import XQueueInterface
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from mock import Mock, patch
from opaque_keys.edx.locator import CourseLocator
from testfixtures import LogCapture
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from lms.djangoapps.certificates.models import (
CertificateStatuses,
ExampleCertificate,
@@ -34,9 +37,6 @@ from lms.djangoapps.certificates.queue import LOGGER, XQueueCertInterface
from lms.djangoapps.certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from lms.djangoapps.verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt
@@ -45,7 +45,7 @@ class XQueueCertInterfaceAddCertificateTest(ModuleStoreTestCase):
"""Test the "add to queue" operation of the XQueue interface. """
def setUp(self):
super(XQueueCertInterfaceAddCertificateTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.user = UserFactory.create()
self.course = CourseFactory.create()
self.enrollment = CourseEnrollmentFactory(
@@ -378,7 +378,7 @@ class XQueueCertInterfaceExampleCertificateTest(TestCase):
ERROR_MSG = 'Kaboom!'
def setUp(self):
super(XQueueCertInterfaceExampleCertificateTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.xqueue = XQueueCertInterface()
def test_add_example_cert(self):

View File

@@ -20,16 +20,16 @@ class CertificateServiceTests(ModuleStoreTestCase):
"""
def setUp(self):
super(CertificateServiceTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.service = CertificateService()
self.course = CourseFactory()
self.user = UserFactory()
self.user_id = self.user.id
self.course_id = self.course.id # lint-amnesty, pylint: disable=no-member
self.course_id = self.course.id # pylint: disable=no-member
GeneratedCertificateFactory.create(
status=CertificateStatuses.downloadable,
user=self.user,
course_id=self.course.id, # lint-amnesty, pylint: disable=no-member
course_id=self.course.id, # pylint: disable=no-member
grade=1.0
)

View File

@@ -40,7 +40,7 @@ class SelfGeneratedCertsSignalTest(ModuleStoreTestCase):
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(SelfGeneratedCertsSignalTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
CertificateGenerationConfiguration.objects.create(enabled=True)
def test_cert_generation_flag_on_pacing_toggle(self):
@@ -48,16 +48,16 @@ class SelfGeneratedCertsSignalTest(ModuleStoreTestCase):
Verify that signal enables or disables self-generated certificates
according to course-pacing.
"""
self.course = CourseFactory.create(self_paced=False, emit_signals=True) # lint-amnesty, pylint: disable=attribute-defined-outside-init
self.assertFalse(cert_generation_enabled(self.course.id))
course = CourseFactory.create(self_paced=False, emit_signals=True)
self.assertFalse(cert_generation_enabled(course.id))
self.course.self_paced = True
self.store.update_item(self.course, self.user.id)
self.assertTrue(cert_generation_enabled(self.course.id))
course.self_paced = True
self.store.update_item(course, self.user.id)
self.assertTrue(cert_generation_enabled(course.id))
self.course.self_paced = False
self.store.update_item(self.course, self.user.id)
self.assertFalse(cert_generation_enabled(self.course.id))
course.self_paced = False
self.store.update_item(course, self.user.id)
self.assertFalse(cert_generation_enabled(course.id))
class WhitelistGeneratedCertificatesTest(ModuleStoreTestCase):
@@ -66,7 +66,7 @@ class WhitelistGeneratedCertificatesTest(ModuleStoreTestCase):
"""
def setUp(self):
super(WhitelistGeneratedCertificatesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory.create(self_paced=True)
self.user = UserFactory.create()
CourseEnrollmentFactory(
@@ -197,7 +197,7 @@ class PassingGradeCertsTest(ModuleStoreTestCase):
"""
def setUp(self):
super(PassingGradeCertsTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory.create(
self_paced=True,
)
@@ -290,7 +290,7 @@ class FailingGradeCertsTest(ModuleStoreTestCase):
"""
def setUp(self):
super(FailingGradeCertsTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory.create(
self_paced=True,
)
@@ -373,7 +373,7 @@ class LearnerTrackChangeCertsTest(ModuleStoreTestCase):
"""
def setUp(self):
super(LearnerTrackChangeCertsTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course_one = CourseFactory.create(self_paced=True)
self.user_one = UserFactory.create()
self.enrollment_one = CourseEnrollmentFactory(
@@ -445,7 +445,7 @@ class CertificateGenerationTaskTest(ModuleStoreTestCase):
"""
def setUp(self):
super(CertificateGenerationTaskTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory.create()
@ddt.data(
@@ -464,7 +464,7 @@ class CertificateGenerationTaskTest(ModuleStoreTestCase):
allowed to generate certificates automatically.
"""
self.user = UserFactory.create()
self.enrollment = CourseEnrollmentFactory( # lint-amnesty, pylint: disable=attribute-defined-outside-init
CourseEnrollmentFactory(
user=self.user,
course_id=self.course.id,
is_active=True,

View File

@@ -21,7 +21,7 @@ from common.djangoapps.student.roles import GlobalStaff, SupportStaffRole
from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.certificates.api import regenerate_user_certificates
from lms.djangoapps.certificates.models import CertificateInvalidation, CertificateStatuses, GeneratedCertificate
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
@@ -56,7 +56,7 @@ class CertificateSupportTestCase(ModuleStoreTestCase):
Create a support team member and a student with a certificate.
Log in as the support team member.
"""
super(CertificateSupportTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
CourseFactory(
org=CertificateSupportTestCase.EXISTED_COURSE_KEY_1.org,
course=CertificateSupportTestCase.EXISTED_COURSE_KEY_1.course,
@@ -79,7 +79,7 @@ class CertificateSupportTestCase(ModuleStoreTestCase):
)
# Create certificates for the student
self.cert = GeneratedCertificate.eligible_certificates.create(
self.cert = GeneratedCertificateFactory(
user=self.student,
course_id=self.CERT_COURSE_KEY,
grade=self.CERT_GRADE,
@@ -104,13 +104,14 @@ class CertificateSearchTests(CertificateSupportTestCase):
"""
Create a course
"""
super(CertificateSearchTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory(
org=self.CERT_COURSE_KEY.org,
course=self.CERT_COURSE_KEY.course,
run=self.CERT_COURSE_KEY.run,
)
self.course.cert_html_view_enabled = True
self.course_key = self.course.id # pylint: disable=no-member
# Course certificate configurations
certificates = [
@@ -126,10 +127,10 @@ class CertificateSearchTests(CertificateSupportTestCase):
]
self.course.certificates = {'certificates': certificates}
self.course.save() # lint-amnesty, pylint: disable=no-member
self.course.save() # pylint: disable=no-member
self.store.update_item(self.course, self.user.id)
self.course_overview = CourseOverviewFactory(
id=self.course.id, # lint-amnesty, pylint: disable=no-member
id=self.course_key,
cert_html_view_enabled=True,
)
@@ -214,7 +215,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
def test_download_link(self):
self.cert.course_id = self.course.id # lint-amnesty, pylint: disable=no-member
self.cert.course_id = self.course_key
self.cert.download_url = ''
self.cert.save()
@@ -252,12 +253,13 @@ class CertificateRegenerateTests(CertificateSupportTestCase):
"""
Create a course and enroll the student in the course.
"""
super(CertificateRegenerateTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory(
org=self.CERT_COURSE_KEY.org,
course=self.CERT_COURSE_KEY.course,
run=self.CERT_COURSE_KEY.run,
)
self.course_key = self.course.id # pylint: disable=no-member
CourseEnrollment.enroll(self.student, self.CERT_COURSE_KEY, self.CERT_MODE)
@ddt.data(
@@ -292,7 +294,7 @@ class CertificateRegenerateTests(CertificateSupportTestCase):
self.cert.save()
response = self._regenerate(
course_key=self.course.id, # lint-amnesty, pylint: disable=no-member
course_key=self.course_key,
username=self.STUDENT_USERNAME,
)
self.assertEqual(response.status_code, 200)
@@ -315,7 +317,7 @@ class CertificateRegenerateTests(CertificateSupportTestCase):
with mock_passing_grade(percent=0.75):
with patch('common.djangoapps.course_modes.models.CourseMode.mode_for_course') as mock_mode_for_course:
mock_mode_for_course.return_value = 'honor'
regenerate_user_certificates(self.student, self.course.id, # lint-amnesty, pylint: disable=no-member
regenerate_user_certificates(self.student, self.course_key,
course=self.course)
mock_generate_cert.assert_called()
@@ -455,12 +457,13 @@ class CertificateGenerateTests(CertificateSupportTestCase):
"""
Create a course and enroll the student in the course.
"""
super(CertificateGenerateTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course = CourseFactory(
org=self.EXISTED_COURSE_KEY_2.org,
course=self.EXISTED_COURSE_KEY_2.course,
run=self.EXISTED_COURSE_KEY_2.run
)
self.course_key = self.course.id # pylint: disable=no-member
CourseEnrollment.enroll(self.student, self.EXISTED_COURSE_KEY_2, self.CERT_MODE)
@ddt.data(
@@ -491,7 +494,7 @@ class CertificateGenerateTests(CertificateSupportTestCase):
def test_generate_certificate(self):
response = self._generate(
course_key=self.course.id, # lint-amnesty, pylint: disable=no-member
course_key=self.course_key,
username=self.STUDENT_USERNAME,
)
self.assertEqual(response.status_code, 200)

View File

@@ -8,13 +8,16 @@ from django.test import TestCase
from mock import call, patch
from opaque_keys.edx.keys import CourseKey
from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.certificates.tasks import generate_certificate
from lms.djangoapps.verify_student.models import IDVerificationAttempt
from common.djangoapps.student.tests.factories import UserFactory
@ddt.ddt
class GenerateUserCertificateTest(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
class GenerateUserCertificateTest(TestCase):
"""
Tests for course certificates
"""
@patch('lms.djangoapps.certificates.tasks.generate_user_certificates')
@patch('lms.djangoapps.certificates.tasks.User.objects.get')

View File

@@ -54,7 +54,7 @@ class UpdateExampleCertificateViewTest(CacheIsolationTestCase):
ENABLED_CACHES = ['default']
def setUp(self):
super(UpdateExampleCertificateViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.cert_set = ExampleCertificateSet.objects.create(course_key=self.COURSE_KEY)
self.cert = ExampleCertificate.objects.create(
example_cert_set=self.cert_set,
@@ -206,7 +206,7 @@ class CertificatesViewsSiteTests(ModuleStoreTestCase):
}"""
def setUp(self):
super(CertificatesViewsSiteTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.client = Client()
self.course = CourseFactory.create(
org='testorg',

View File

@@ -13,12 +13,18 @@ from django.conf import settings
from django.test.client import Client, RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
from edx_toggles.toggles import LegacyWaffleSwitch
from edx_toggles.toggles.testutils import override_waffle_switch
from mock import patch
from organizations import api as organizations_api
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from common.djangoapps.course_modes.models import CourseMode
from edx_toggles.toggles import LegacyWaffleSwitch # lint-amnesty, pylint: disable=wrong-import-order
from edx_toggles.toggles.testutils import override_waffle_switch # lint-amnesty, pylint: disable=wrong-import-order
from common.djangoapps.student.roles import CourseStaffRole
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from common.djangoapps.track.tests import EventTrackingTestCase
from common.djangoapps.util.date_utils import strftime_localized
from lms.djangoapps.badges.events.course_complete import get_completion_badge
from lms.djangoapps.badges.tests.factories import (
BadgeAssertionFactory,
@@ -27,19 +33,18 @@ from lms.djangoapps.badges.tests.factories import (
)
from lms.djangoapps.certificates.models import (
CertificateGenerationCourseSetting,
CertificateHtmlViewConfiguration,
CertificateSocialNetworks,
CertificateStatuses,
CertificateTemplate,
CertificateTemplateAsset,
GeneratedCertificate
)
from lms.djangoapps.certificates.utils import get_certificate_url
from lms.djangoapps.certificates.tests.factories import (
CertificateHtmlViewConfigurationFactory,
GeneratedCertificateFactory,
LinkedInAddToProfileConfigurationFactory
)
from lms.djangoapps.certificates.utils import get_certificate_url
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from openedx.core.djangoapps.certificates.config import waffle
from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
@@ -50,12 +55,6 @@ from openedx.core.djangoapps.site_configuration.tests.test_util import (
from openedx.core.djangolib.js_utils import js_escaped_string
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
from openedx.core.lib.tests.assertions.events import assert_event_matches
from common.djangoapps.student.roles import CourseStaffRole
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from common.djangoapps.track.tests import EventTrackingTestCase
from common.djangoapps.util.date_utils import strftime_localized
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
AUTO_CERTIFICATE_GENERATION_SWITCH = LegacyWaffleSwitch(waffle.waffle(), waffle.AUTO_CERTIFICATE_GENERATION)
FEATURES_WITH_CERTS_ENABLED = settings.FEATURES.copy()
@@ -80,7 +79,7 @@ class CommonCertificatesTestCase(ModuleStoreTestCase):
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(CommonCertificatesTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.client = Client()
self.course = CourseFactory.create(
org='testorg',
@@ -249,7 +248,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase, CacheIsolationTestCase)
"""
def setUp(self):
super(CertificatesViewsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.mock_course_run_details = {
'content_language': 'en',
'weeks_to_complete': '4',

View File

@@ -11,7 +11,12 @@ from django.conf import settings
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import patch
from pytz import UTC
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from common.djangoapps.util.milestones_helpers import milestones_achieved_by_user, set_prerequisite_courses
from lms.djangoapps.badges.tests.factories import CourseCompleteImageConfigurationFactory
from lms.djangoapps.certificates.models import (
CertificateStatuses,
@@ -20,11 +25,6 @@ from lms.djangoapps.certificates.models import (
certificate_status_for_student
)
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from common.djangoapps.util.milestones_helpers import milestones_achieved_by_user, set_prerequisite_courses
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@ddt
@@ -34,7 +34,7 @@ class CertificatesModelTest(ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
def setUp(self):
super(CertificatesModelTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
today = datetime.now(UTC)
self.instructor_paced_course = CourseFactory.create(
@@ -71,7 +71,7 @@ class CertificatesModelTest(ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
student = UserFactory()
student.profile.allow_certificate = allow_certificate
student.profile.save() # lint-amnesty, pylint: disable=no-member
student.profile.save() # pylint: disable=no-member
# for instructor paced course
certificate_info = certificate_info_for_user(
@@ -106,7 +106,7 @@ class CertificatesModelTest(ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
student = UserFactory()
student.profile.allow_certificate = allow_certificate
student.profile.save() # lint-amnesty, pylint: disable=no-member
student.profile.save() # pylint: disable=no-member
certificate1 = GeneratedCertificateFactory.create(
user=student,
@@ -161,7 +161,7 @@ class CertificatesModelTest(ModuleStoreTestCase, MilestonesTestCaseMixin):
student_no_certs = UserFactory()
student_with_certs = UserFactory()
student_with_certs.profile.allow_certificate = True
student_with_certs.profile.save() # lint-amnesty, pylint: disable=no-member
student_with_certs.profile.save() # pylint: disable=no-member
# Set up a couple of courses
course_1 = CourseFactory.create()