refactor: ran pyupgrade on lms/djangoapps/certificates (#26740)
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
import uuid
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
import ddt
|
||||
import pytz
|
||||
import six
|
||||
from config_models.models import cache
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
@@ -18,7 +18,6 @@ from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
from freezegun import freeze_time
|
||||
from mock import patch
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from testfixtures import LogCapture
|
||||
@@ -44,13 +43,13 @@ from lms.djangoapps.certificates.api import (
|
||||
generate_user_certificates,
|
||||
get_allowlist_entry,
|
||||
get_allowlisted_users,
|
||||
get_certificate_for_user,
|
||||
get_certificates_for_user,
|
||||
get_certificates_for_user_by_course_keys,
|
||||
get_certificate_footer_context,
|
||||
get_certificate_for_user,
|
||||
get_certificate_header_context,
|
||||
get_certificate_invalidation_entry,
|
||||
get_certificate_url,
|
||||
get_certificates_for_user,
|
||||
get_certificates_for_user_by_course_keys,
|
||||
is_certificate_invalidated,
|
||||
is_on_allowlist,
|
||||
remove_allowlist_entry,
|
||||
@@ -79,7 +78,7 @@ FEATURES_WITH_CERTS_ENABLED = settings.FEATURES.copy()
|
||||
FEATURES_WITH_CERTS_ENABLED['CERTIFICATES_HTML_VIEW'] = True
|
||||
|
||||
|
||||
class WebCertificateTestMixin(object):
|
||||
class WebCertificateTestMixin:
|
||||
"""
|
||||
Mixin with helpers for testing Web Certificates.
|
||||
"""
|
||||
@@ -358,7 +357,7 @@ class CertificateGetTests(SharedModuleStoreTestCase):
|
||||
cls.freezer = freeze_time(cls.now)
|
||||
cls.freezer.start()
|
||||
|
||||
super(CertificateGetTests, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
cls.student = UserFactory()
|
||||
cls.student_no_cert = UserFactory()
|
||||
cls.uuid = uuid.uuid4().hex
|
||||
@@ -409,7 +408,7 @@ class CertificateGetTests(SharedModuleStoreTestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(CertificateGetTests, cls).tearDownClass()
|
||||
super().tearDownClass()
|
||||
cls.freezer.stop()
|
||||
|
||||
def test_get_certificate_for_user(self):
|
||||
@@ -560,7 +559,7 @@ class GenerateUserCertificatesTest(EventTestMixin, WebCertificateTestMixin, Modu
|
||||
self.assert_event_emitted(
|
||||
'edx.certificate.created',
|
||||
user_id=self.student.id,
|
||||
course_id=six.text_type(self.course.id),
|
||||
course_id=str(self.course.id),
|
||||
certificate_url=get_certificate_url(self.student.id, self.course.id),
|
||||
certificate_id=cert.verify_uuid,
|
||||
enrollment_mode=cert.mode,
|
||||
@@ -651,7 +650,7 @@ class CertificateGenerationEnabledTest(EventTestMixin, TestCase):
|
||||
event_name = '.'.join(['edx', 'certificate', 'generation', cert_event_type])
|
||||
self.assert_event_emitted(
|
||||
event_name,
|
||||
course_id=six.text_type(self.COURSE_KEY),
|
||||
course_id=str(self.COURSE_KEY),
|
||||
)
|
||||
|
||||
self._assert_enabled_for_course(self.COURSE_KEY, expect_enabled)
|
||||
@@ -775,8 +774,7 @@ class CertificatesBrandingTest(ModuleStoreTestCase):
|
||||
data = get_certificate_header_context(is_secure=True)
|
||||
|
||||
# Make sure there are not unexpected keys in dict returned by 'get_certificate_header_context'
|
||||
six.assertCountEqual(
|
||||
self,
|
||||
self.assertCountEqual(
|
||||
list(data.keys()),
|
||||
['logo_src', 'logo_url']
|
||||
)
|
||||
@@ -795,8 +793,7 @@ class CertificatesBrandingTest(ModuleStoreTestCase):
|
||||
data = get_certificate_footer_context()
|
||||
|
||||
# Make sure there are not unexpected keys in dict returned by 'get_certificate_footer_context'
|
||||
six.assertCountEqual(
|
||||
self,
|
||||
self.assertCountEqual(
|
||||
list(data.keys()),
|
||||
['company_about_url', 'company_privacy_url', 'company_tos_url']
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user