Skip to content
Snippets Groups Projects
Unverified Commit 87f5faf5 authored by Diana Huang's avatar Diana Huang Committed by GitHub
Browse files

Merge pull request #26688 from edx/revert-26649-bom-2368

Revert "BOM-2368: pyupgrade in LMS Directory"
parents 23f34031 f8446819
No related branches found
No related tags found
No related merge requests found
Showing
with 410 additions and 401 deletions
......@@ -12,10 +12,9 @@ registration and discovery can work correctly.
# FWIW, this is identical behavior to what happens in Kombu if pkg_resources
# isn't available.
import kombu.utils
kombu.utils.entrypoints = lambda namespace: iter([])
# This will make sure the app is always imported when Django starts so
# that shared_task will use this app, and also ensures that the celery
# singleton is always configured for the LMS.
from .celery import APP as CELERY_APP # lint-amnesty, pylint: disable=wrong-import-position
kombu.utils.entrypoints = lambda namespace: iter([])
......@@ -7,8 +7,8 @@ Taken from: https://celery.readthedocs.org/en/latest/django/first-steps-with-dja
import os
from openedx.core.lib.celery import APP # pylint: disable=wrong-import-position,unused-import
# Set the default Django settings module for the 'celery' program
# and then instantiate the Celery singleton.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lms.envs.production')
from openedx.core.lib.celery import APP # pylint: disable=wrong-import-position,unused-import
......@@ -11,7 +11,7 @@ workers = 17
def pre_request(worker, req):
worker.log.info(f"{req.method} {req.path}")
worker.log.info("%s %s" % (req.method, req.path))
def close_all_caches():
......
# -*- coding: utf-8 -*-
"""
Settings for Bok Choy tests that are used when running LMS.
......@@ -34,11 +35,11 @@ TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root"
os.environ['SERVICE_VARIANT'] = 'bok_choy_docker' if 'BOK_CHOY_HOSTNAME' in os.environ else 'bok_choy'
os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml",
config_root=CONFIG_ROOT, service_variant=os.environ['SERVICE_VARIANT'])
os.environ['REVISION_CFG'] = f"{CONFIG_ROOT}/revisions.yml"
os.environ['REVISION_CFG'] = "{config_root}/revisions.yml".format(config_root=CONFIG_ROOT)
from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position
######################### Testing overrides ####################################
# Redirect to the test_root folder within the repo
......@@ -57,8 +58,8 @@ update_module_store_settings(
default_store=os.environ.get('DEFAULT_STORE', 'draft'),
)
PLATFORM_NAME = ugettext_lazy("édX")
PLATFORM_DESCRIPTION = ugettext_lazy("Open édX Platform")
PLATFORM_NAME = ugettext_lazy(u"édX")
PLATFORM_DESCRIPTION = ugettext_lazy(u"Open édX Platform")
############################ STATIC FILES #############################
......@@ -100,9 +101,9 @@ YOUTUBE_HOSTNAME = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1')
# Point the URL used to test YouTube availability to our stub YouTube server
YOUTUBE_PORT = 9080
YOUTUBE['TEST_TIMEOUT'] = 5000
YOUTUBE['API'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/get_youtube_api/"
YOUTUBE['METADATA_URL'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/test_youtube/"
YOUTUBE['TEXT_API']['url'] = f"{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/test_transcripts_youtube/"
YOUTUBE['API'] = "http://{0}:{1}/get_youtube_api/".format(YOUTUBE_HOSTNAME, YOUTUBE_PORT)
YOUTUBE['METADATA_URL'] = "http://{0}:{1}/test_youtube/".format(YOUTUBE_HOSTNAME, YOUTUBE_PORT)
YOUTUBE['TEXT_API']['url'] = "{0}:{1}/test_transcripts_youtube/".format(YOUTUBE_HOSTNAME, YOUTUBE_PORT)
############################# SECURITY SETTINGS ################################
# Default to advanced security in common.py, so tests can reset here to use
......
# -*- coding: utf-8 -*-
"""
Settings for Bok Choy tests that are used when running Studio in Docker-based devstack.
"""
# noinspection PyUnresolvedReferences
from .bok_choy import * # pylint: disable=wildcard-import
CMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_CMS_PORT', 8031))
LMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_LMS_PORT', 8003))
LMS_ROOT_URL = f'http://{LMS_BASE}'
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)
LOGIN_REDIRECT_WHITELIST = [CMS_BASE]
SITE_NAME = LMS_BASE
......@@ -22,6 +24,6 @@ LOGGING['loggers']['tracking']['handlers'] = ['console']
# Point the URL used to test YouTube availability to our stub YouTube server
BOK_CHOY_HOST = os.environ['BOK_CHOY_HOSTNAME']
YOUTUBE['API'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/get_youtube_api/"
YOUTUBE['METADATA_URL'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/test_youtube/"
YOUTUBE['TEXT_API']['url'] = f"{BOK_CHOY_HOST}:{YOUTUBE_PORT}/test_transcripts_youtube/"
YOUTUBE['API'] = "http://{}:{}/get_youtube_api/".format(BOK_CHOY_HOST, YOUTUBE_PORT)
YOUTUBE['METADATA_URL'] = "http://{}:{}/test_youtube/".format(BOK_CHOY_HOST, YOUTUBE_PORT)
YOUTUBE['TEXT_API']['url'] = "{}:{}/test_transcripts_youtube/".format(BOK_CHOY_HOST, YOUTUBE_PORT)
This diff is collapsed.
......@@ -8,6 +8,7 @@ import logging
from os.path import abspath, dirname, join
from corsheaders.defaults import default_headers as corsheaders_default_headers
# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value
#####################################################################
from edx_django_utils.plugins import add_plugins
......@@ -33,9 +34,9 @@ SITE_NAME = LMS_BASE
CELERY_ALWAYS_EAGER = True
HTTPS = 'off'
LMS_ROOT_URL = f'http://{LMS_BASE}'
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)
LMS_INTERNAL_ROOT_URL = LMS_ROOT_URL
ENTERPRISE_API_URL = f'{LMS_INTERNAL_ROOT_URL}/enterprise/api/v1/'
ENTERPRISE_API_URL = '{}/enterprise/api/v1/'.format(LMS_INTERNAL_ROOT_URL)
IDA_LOGOUT_URI_LIST = [
'http://localhost:18130/logout/', # ecommerce
'http://localhost:18150/logout/', # credentials
......@@ -279,10 +280,10 @@ LOGIN_REDIRECT_WHITELIST = [
###################### JWTs ######################
JWT_AUTH.update({
'JWT_AUDIENCE': 'lms-key',
'JWT_ISSUER': f'{LMS_ROOT_URL}/oauth2',
'JWT_ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'JWT_ISSUERS': [{
'AUDIENCE': 'lms-key',
'ISSUER': f'{LMS_ROOT_URL}/oauth2',
'ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'SECRET_KEY': 'lms-secret',
}],
'JWT_SECRET_KEY': 'lms-secret',
......@@ -381,7 +382,7 @@ ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
CREDENTIALS_SERVICE_USERNAME = 'credentials_worker'
COURSE_CATALOG_URL_ROOT = 'http://edx.devstack.discovery:18381'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", SYSTEM_WIDE_ROLE_CLASSES)
SYSTEM_WIDE_ROLE_CLASSES.append(
......
......@@ -7,6 +7,7 @@ import logging
from os.path import abspath, dirname, join
from corsheaders.defaults import default_headers as corsheaders_default_headers
# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value
#####################################################################
from edx_django_utils.plugins import add_plugins
......@@ -32,9 +33,9 @@ SITE_NAME = LMS_BASE
CELERY_ALWAYS_EAGER = True
HTTPS = 'off'
LMS_ROOT_URL = f'http://{LMS_BASE}'
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)
LMS_INTERNAL_ROOT_URL = LMS_ROOT_URL
ENTERPRISE_API_URL = f'{LMS_INTERNAL_ROOT_URL}/enterprise/api/v1/'
ENTERPRISE_API_URL = '{}/enterprise/api/v1/'.format(LMS_INTERNAL_ROOT_URL)
IDA_LOGOUT_URI_LIST = [
'http://localhost:18130/logout/', # ecommerce
'http://localhost:18150/logout/', # credentials
......@@ -217,10 +218,10 @@ LOGIN_REDIRECT_WHITELIST = [CMS_BASE]
###################### JWTs ######################
JWT_AUTH.update({
'JWT_AUDIENCE': 'lms-key',
'JWT_ISSUER': f'{LMS_ROOT_URL}/oauth2',
'JWT_ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'JWT_ISSUERS': [{
'AUDIENCE': 'lms-key',
'ISSUER': f'{LMS_ROOT_URL}/oauth2',
'ISSUER': '{}/oauth2'.format(LMS_ROOT_URL),
'SECRET_KEY': 'lms-secret',
}],
'JWT_SECRET_KEY': 'lms-secret',
......@@ -320,7 +321,7 @@ ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
CREDENTIALS_SERVICE_USERNAME = 'credentials_worker'
COURSE_CATALOG_URL_ROOT = 'http://edx.devstack.discovery:18381'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", SYSTEM_WIDE_ROLE_CLASSES)
SYSTEM_WIDE_ROLE_CLASSES.append(
......
......@@ -21,10 +21,9 @@ invoked each time that changes have been made.
import os # lint-amnesty, pylint: disable=unused-import
from .devstack import * # pylint: disable=wildcard-import
########################## Devstack settings ###################################
from .devstack import * # pylint: disable=wildcard-import
TEST_ROOT = REPO_ROOT / "test_root"
......
......@@ -14,6 +14,9 @@ In two separate processes on devstack:
import os # lint-amnesty, pylint: disable=unused-import
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=wildcard-import, unused-wildcard-import
from lms.envs.devstack import *
# Require a separate celery worker
......
# -*- coding: utf-8 -*-
"""
This is the default template for our main set of AWS servers.
......@@ -41,7 +43,7 @@ def get_env_setting(setting):
try:
return os.environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
error_msg = u"Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg) # lint-amnesty, pylint: disable=raise-missing-from
################################ ALWAYS THE SAME ##############################
......@@ -133,11 +135,11 @@ CELERYD_PREFETCH_MULTIPLIER = 1
QUEUE_VARIANT = CONFIG_PREFIX.lower()
CELERY_DEFAULT_EXCHANGE = f'edx.{QUEUE_VARIANT}core'
CELERY_DEFAULT_EXCHANGE = 'edx.{0}core'.format(QUEUE_VARIANT)
HIGH_PRIORITY_QUEUE = f'edx.{QUEUE_VARIANT}core.high'
DEFAULT_PRIORITY_QUEUE = f'edx.{QUEUE_VARIANT}core.default'
HIGH_MEM_QUEUE = f'edx.{QUEUE_VARIANT}core.high_mem'
HIGH_PRIORITY_QUEUE = 'edx.{0}core.high'.format(QUEUE_VARIANT)
DEFAULT_PRIORITY_QUEUE = 'edx.{0}core.default'.format(QUEUE_VARIANT)
HIGH_MEM_QUEUE = 'edx.{0}core.high_mem'.format(QUEUE_VARIANT)
CELERY_DEFAULT_QUEUE = DEFAULT_PRIORITY_QUEUE
CELERY_DEFAULT_ROUTING_KEY = DEFAULT_PRIORITY_QUEUE
......@@ -358,7 +360,7 @@ if "TRACKING_IGNORE_URL_PATTERNS" in ENV_TOKENS:
SSL_AUTH_EMAIL_DOMAIN = ENV_TOKENS.get("SSL_AUTH_EMAIL_DOMAIN", "MIT.EDU")
SSL_AUTH_DN_FORMAT_STRING = ENV_TOKENS.get(
"SSL_AUTH_DN_FORMAT_STRING",
"/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}"
u"/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}"
)
# Video Caching. Pairing country codes with CDN URLs.
......@@ -532,11 +534,11 @@ CELERY_BROKER_VHOST = ENV_TOKENS.get("CELERY_BROKER_VHOST", "")
CELERY_BROKER_USER = AUTH_TOKENS.get("CELERY_BROKER_USER", "")
CELERY_BROKER_PASSWORD = AUTH_TOKENS.get("CELERY_BROKER_PASSWORD", "")
BROKER_URL = "{}://{}:{}@{}/{}".format(CELERY_BROKER_TRANSPORT,
CELERY_BROKER_USER,
CELERY_BROKER_PASSWORD,
CELERY_BROKER_HOSTNAME,
CELERY_BROKER_VHOST)
BROKER_URL = "{0}://{1}:{2}@{3}/{4}".format(CELERY_BROKER_TRANSPORT,
CELERY_BROKER_USER,
CELERY_BROKER_PASSWORD,
CELERY_BROKER_HOSTNAME,
CELERY_BROKER_VHOST)
BROKER_USE_SSL = ENV_TOKENS.get('CELERY_BROKER_USE_SSL', False)
BROKER_TRANSPORT_OPTIONS = {
......
# -*- coding: utf-8 -*-
"""
This config file runs the simplest dev environment using sqlite, and db-based
sessions. Assumes structure:
......@@ -17,15 +18,15 @@ import logging
import os
from collections import OrderedDict
from random import choice # lint-amnesty, pylint: disable=unused-import
from string import ascii_letters, digits, punctuation # lint-amnesty, pylint: disable=unused-import
from string import digits, ascii_letters, punctuation # lint-amnesty, pylint: disable=unused-import
from uuid import uuid4
import openid.oidutil
from django.utils.translation import ugettext_lazy
from edx_django_utils.plugins import add_plugins
from path import Path as path
from six.moves import range # lint-amnesty, pylint: disable=unused-import
from common.djangoapps.util.testing import patch_sessions, patch_testcase # pylint: disable=wrong-import-order
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType
from openedx.core.lib.derived import derive_settings
from openedx.core.lib.tempdir import mkdtemp_clean
......@@ -33,6 +34,8 @@ from xmodule.modulestore.modulestore_settings import update_module_store_setting
from .common import *
from common.djangoapps.util.testing import patch_sessions, patch_testcase # pylint: disable=wrong-import-order
# This patch disables the commit_on_success decorator during tests
# in TestCase subclasses.
patch_testcase()
......@@ -127,7 +130,7 @@ COMMENTS_SERVICE_URL = 'http://localhost:4567'
DJFS = {
'type': 'osfs',
'directory_root': f'{DATA_DIR}/django-pyfs/static/django-pyfs',
'directory_root': '{}/django-pyfs/static/django-pyfs'.format(DATA_DIR),
'url_root': '/static/django-pyfs',
}
......@@ -165,7 +168,7 @@ update_module_store_settings(
doc_store_settings={
'host': MONGO_HOST,
'port': MONGO_PORT_NUM,
'db': f'test_xmodule_{THIS_UUID}',
'db': 'test_xmodule_{}'.format(THIS_UUID),
'collection': 'test_modulestore',
},
)
......@@ -174,7 +177,7 @@ CONTENTSTORE = {
'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore',
'DOC_STORE_CONFIG': {
'host': MONGO_HOST,
'db': f'test_xcontent_{THIS_UUID}',
'db': 'test_xcontent_{}'.format(THIS_UUID),
'port': MONGO_PORT_NUM,
}
}
......@@ -381,8 +384,8 @@ openid.oidutil.log = lambda message, level=0: None
# Include a non-ascii character in PLATFORM_NAME and PLATFORM_DESCRIPTION to uncover possible
# UnicodeEncodeErrors in tests. Also use lazy text to reveal possible json dumps errors
PLATFORM_NAME = ugettext_lazy("édX")
PLATFORM_DESCRIPTION = ugettext_lazy("Open édX Platform")
PLATFORM_NAME = ugettext_lazy(u"édX")
PLATFORM_DESCRIPTION = ugettext_lazy(u"Open édX Platform")
SITE_NAME = "edx.org"
......@@ -475,7 +478,7 @@ COURSE_BLOCKS_API_EXTRA_FIELDS = [
]
COURSE_CATALOG_URL_ROOT = 'https://catalog.example.com'
COURSE_CATALOG_API_URL = f'{COURSE_CATALOG_URL_ROOT}/api/v1'
COURSE_CATALOG_API_URL = '{}/api/v1'.format(COURSE_CATALOG_URL_ROOT)
COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes", REPO_ROOT / "common/test"]
COMPREHENSIVE_THEME_LOCALE_PATHS = [REPO_ROOT / "themes/conf/locale", ]
......
......@@ -7,10 +7,10 @@ This file contains implementation override of SearchFilterGenerator which will a
import six
from search.filter_generator import SearchFilterGenerator
from common.djangoapps.student.models import CourseEnrollment
from openedx.core.djangoapps.course_groups.partition_scheme import CohortPartitionScheme
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
from common.djangoapps.student.models import CourseEnrollment
INCLUDE_SCHEMES = [CohortPartitionScheme, RandomUserPartitionScheme, ]
SCHEME_SUPPORTS_ASSIGNMENT = [RandomUserPartitionScheme, ]
......@@ -29,12 +29,12 @@ class LmsSearchFilterGenerator(SearchFilterGenerator):
def field_dictionary(self, **kwargs):
""" add course if provided otherwise add courses in which the user is enrolled in """
field_dictionary = super().field_dictionary(**kwargs)
field_dictionary = super(LmsSearchFilterGenerator, self).field_dictionary(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
if not kwargs.get('user'):
field_dictionary['course'] = []
elif not kwargs.get('course_id'):
user_enrollments = self._enrollments_for_user(kwargs['user'])
field_dictionary['course'] = [str(enrollment.course_id) for enrollment in user_enrollments]
field_dictionary['course'] = [six.text_type(enrollment.course_id) for enrollment in user_enrollments]
# if we have an org filter, only include results for this org filter
course_org_filter = configuration_helpers.get_current_site_orgs()
......@@ -47,7 +47,7 @@ class LmsSearchFilterGenerator(SearchFilterGenerator):
"""
Exclude any courses defined outside the current org.
"""
exclude_dictionary = super().exclude_dictionary(**kwargs)
exclude_dictionary = super(LmsSearchFilterGenerator, self).exclude_dictionary(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
course_org_filter = configuration_helpers.get_current_site_orgs()
# If we have a course filter we are ensuring that we only get those courses above
if not course_org_filter:
......
......@@ -3,13 +3,12 @@ Tests for the lms_filter_generator
"""
from unittest.mock import Mock, patch
import six
from mock import Mock, patch
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import UserFactory
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
......@@ -53,7 +52,7 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
)
def setUp(self):
super().setUp()
super(LmsSearchFilterGeneratorTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_courses()
self.user = UserFactory.create(username="jack", email="jack@fake.edx.org", password='test')
......@@ -67,8 +66,8 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
assert 'start_date' in filter_dictionary
assert str(self.courses[0].id) in field_dictionary['course']
assert str(self.courses[1].id) in field_dictionary['course']
assert six.text_type(self.courses[0].id) in field_dictionary['course']
assert six.text_type(self.courses[1].id) in field_dictionary['course']
def test_course_id_provided(self):
"""
......@@ -76,11 +75,11 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
"""
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user,
course_id=str(self.courses[0].id)
course_id=six.text_type(self.courses[0].id)
)
assert 'start_date' in filter_dictionary
assert str(self.courses[0].id) == field_dictionary['course']
assert six.text_type(self.courses[0].id) == field_dictionary['course']
def test_user_not_provided(self):
"""
......
......@@ -3,6 +3,7 @@ Tests for the lms_result_processor
"""
import six
import pytest
from lms.djangoapps.courseware.tests.factories import UserFactory
......@@ -63,7 +64,7 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
)
def setUp(self):
super().setUp()
super(LmsSearchResultProcessorTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_course()
def test_url_parameter(self):
......@@ -75,15 +76,15 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
srp = LmsSearchResultProcessor(
{
"course": str(self.course.id),
"id": str(self.html.scope_ids.usage_id),
"course": six.text_type(self.course.id),
"id": six.text_type(self.html.scope_ids.usage_id),
"content": {"text": "This is the html text"}
},
"test"
)
assert srp.url == '/courses/{}/jump_to/{}'.format(str(self.course.id),
str(self.html.scope_ids.usage_id))
assert srp.url == '/courses/{}/jump_to/{}'.format(six.text_type(self.course.id),
six.text_type(self.html.scope_ids.usage_id))
def test_should_remove(self):
"""
......@@ -91,8 +92,8 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
"""
srp = LmsSearchResultProcessor(
{
"course": str(self.course.id),
"id": str(self.html.scope_ids.usage_id),
"course": six.text_type(self.course.id),
"id": six.text_type(self.html.scope_ids.usage_id),
"content": {"text": "This is html test text"}
},
"test"
......
......@@ -18,7 +18,7 @@ class LmsUtilsTest(ModuleStoreTestCase):
"""
Setup a dummy course content.
"""
super().setUp()
super(LmsUtilsTest, self).setUp()
with self.store.default_store(ModuleStoreEnum.Type.mongo):
self.course = CourseFactory.create()
......
......@@ -70,7 +70,7 @@ class XBlockValidationTest(LmsXBlockMixinTestCase):
Unit tests for XBlock validation
"""
def setUp(self):
super().setUp()
super(XBlockValidationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_course()
def verify_validation_message(self, message, expected_message, expected_message_type):
......@@ -280,7 +280,7 @@ class OpenAssessmentBlockMixinTestCase(ModuleStoreTestCase):
"""
def setUp(self):
super().setUp()
super(OpenAssessmentBlockMixinTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
self.section = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section')
self.open_assessment = ItemFactory.create(
......@@ -378,7 +378,7 @@ def ddt_named(parent, child):
Helper to get more readable dynamically-generated test names from ddt.
"""
args = RenamedTuple([parent, child])
args.__name__ = f'parent_{parent}_child_{child}' # pylint: disable=attribute-defined-outside-init
args.__name__ = 'parent_{}_child_{}'.format(parent, child) # pylint: disable=attribute-defined-outside-init
return args
......@@ -406,7 +406,7 @@ class XBlockMergedGroupAccessTest(LmsXBlockMixinTestCase):
)
def setUp(self):
super().setUp()
super(XBlockMergedGroupAccessTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.build_course()
def verify_group_access(self, block_location, expected_dict):
......
......@@ -4,6 +4,7 @@
import logging
import mimetypes
from django.conf import settings # lint-amnesty, pylint: disable=unused-import
from django.test import TestCase
log = logging.getLogger(__name__)
......
......@@ -14,9 +14,8 @@ from edx_api_doc_tools import make_docs_urls
from edx_django_utils.plugins import get_plugin_url_patterns
from ratelimitbackend import admin
from common.djangoapps.student import views as student_views
from common.djangoapps.util import views as util_views
from lms.djangoapps.branding import views as branding_views
from lms.djangoapps.debug import views as debug_views
from lms.djangoapps.certificates import views as certificates_views
from lms.djangoapps.courseware.masquerade import MasqueradeView
from lms.djangoapps.courseware.module_render import (
......@@ -28,14 +27,13 @@ from lms.djangoapps.courseware.module_render import (
from lms.djangoapps.courseware.views import views as courseware_views
from lms.djangoapps.courseware.views.index import CoursewareIndex
from lms.djangoapps.courseware.views.views import CourseTabView, EnrollStaffView, StaticCourseTabView
from lms.djangoapps.debug import views as debug_views
from lms.djangoapps.discussion import views as discussion_views
from lms.djangoapps.discussion.config.settings import is_forum_daily_digest_enabled
from lms.djangoapps.discussion.notification_prefs import views as notification_prefs_views
from lms.djangoapps.instructor.views import instructor_dashboard as instructor_dashboard_views
from lms.djangoapps.instructor_task import views as instructor_task_views
from lms.djangoapps.static_template_view import views as static_template_view_views
from lms.djangoapps.staticbook import views as staticbook_views
from lms.djangoapps.static_template_view import views as static_template_view_views
from openedx.core.apidocs import api_info
from openedx.core.djangoapps.auth_exchange.views import LoginWithAccessTokenView
from openedx.core.djangoapps.catalog.models import CatalogIntegration
......@@ -54,6 +52,8 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
from openedx.core.djangoapps.user_authn.views.login import redirect_to_lms_login
from openedx.core.djangoapps.verified_track_content import views as verified_track_content_views
from openedx.features.enterprise_support.api import enterprise_enabled
from common.djangoapps.student import views as student_views
from common.djangoapps.util import views as util_views
RESET_COURSE_DEADLINES_NAME = 'reset_course_deadlines'
RENDER_XBLOCK_NAME = 'render_xblock'
......@@ -256,9 +256,9 @@ if settings.WIKI_ENABLED:
# These urls are for viewing the wiki in the context of a course. They should
# never be returned by a reverse() so they come after the other url patterns
url(fr'^courses/{settings.COURSE_ID_PATTERN}/course_wiki/?$',
url(r'^courses/{}/course_wiki/?$'.format(settings.COURSE_ID_PATTERN),
course_wiki_views.course_wiki_redirect, name='course_wiki'),
url(fr'^courses/{settings.COURSE_KEY_REGEX}/wiki/',
url(r'^courses/{}/wiki/'.format(settings.COURSE_KEY_REGEX),
include((wiki_url_patterns, 'course_wiki_do_not_reverse'), namespace='course_wiki_do_not_reverse')),
]
......@@ -314,7 +314,7 @@ urlpatterns += [
# passed as a 'view' parameter to the URL.
# Note: This is not an API. Compare this with the xblock_view API above.
url(
fr'^xblock/{settings.USAGE_KEY_PATTERN}$',
r'^xblock/{usage_key_string}$'.format(usage_key_string=settings.USAGE_KEY_PATTERN),
courseware_views.render_xblock,
name=RENDER_XBLOCK_NAME,
),
......@@ -664,7 +664,7 @@ urlpatterns += [
# Calendar Sync UI in LMS
url(
fr'^courses/{settings.COURSE_ID_PATTERN}/',
r'^courses/{}/'.format(settings.COURSE_ID_PATTERN,),
include('openedx.features.calendar_sync.urls'),
),
......@@ -912,7 +912,7 @@ urlpatterns += [
# Custom courses on edX (CCX) URLs
if settings.FEATURES.get('CUSTOM_COURSES_EDX'):
urlpatterns += [
url(fr'^courses/{settings.COURSE_ID_PATTERN}/',
url(r'^courses/{}/'.format(settings.COURSE_ID_PATTERN),
include('lms.djangoapps.ccx.urls')),
url(r'^api/ccx/', include(('lms.djangoapps.ccx.api.urls', 'lms.djangoapps.ccx'), namespace='ccx_api')),
]
......
......@@ -8,32 +8,28 @@ It exposes a module-level variable named ``application``. Django's
``WSGI_APPLICATION`` setting.
"""
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
# Disable PyContract contract checking when running as a webserver
import contracts # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import \
get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
# Patch the xml libs
from safe_lxml import defuse_xml_libs
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-position
defuse_xml_libs()
# Disable PyContract contract checking when running as a webserver
import contracts # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
contracts.disable_all()
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws")
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
startup.run()
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-position
# Trigger a forced initialization of our modulestores since this can take a
# while to complete and we want this done before HTTP requests are accepted.
modulestore()
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
application = get_wsgi_application()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment