Applied pylint-amnesty
This commit is contained in:
@@ -32,8 +32,8 @@ class Command(BaseCommand):
|
||||
# Remove all redundant Mac OS metadata files
|
||||
assets_deleted = content_store.remove_redundant_content_for_courses()
|
||||
success = True
|
||||
except Exception as err:
|
||||
log.info("=" * 30 + u"> failed to cleanup")
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except
|
||||
log.info("=" * 30 + u"> failed to cleanup") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
log.info("Error:")
|
||||
log.info(err)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Django management command to create a course in a specific modulestore
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from six import text_type
|
||||
|
||||
@@ -53,7 +53,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
user_object = user_from_str(user)
|
||||
except User.DoesNotExist:
|
||||
raise CommandError(u"No user {user} found.".format(user=user))
|
||||
raise CommandError(u"No user {user} found.".format(user=user)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
return user_object
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
@@ -68,7 +68,7 @@ class Command(BaseCommand):
|
||||
course_key = text_type(options['course_key'])
|
||||
course_key = CourseKey.from_string(course_key)
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u'Invalid course_key: {}'.format(options['course_key']))
|
||||
raise CommandError(u'Invalid course_key: {}'.format(options['course_key'])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().get_course(course_key):
|
||||
raise CommandError(u'Course not found: {}'.format(options['course_key']))
|
||||
@@ -81,6 +81,6 @@ class Command(BaseCommand):
|
||||
|
||||
if options['remove_assets']:
|
||||
contentstore().delete_all_course_assets(course_key)
|
||||
print(u'Deleted assets for course'.format(course_key))
|
||||
print(u'Deleted assets for course'.format(course_key)) # lint-amnesty, pylint: disable=too-many-format-args
|
||||
|
||||
print(u'Deleted course {}'.format(course_key))
|
||||
|
||||
@@ -25,7 +25,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_id'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Invalid course key.")
|
||||
raise CommandError("Invalid course key.") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if options['commit']:
|
||||
print('Deleting orphans from the course:')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
###
|
||||
### Script for editing the course's tabs
|
||||
###
|
||||
@@ -37,7 +38,7 @@ def print_course(course):
|
||||
# {u'type': u'progress', u'name': u'Progress'}]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
help = """See and edit a course's tabs list. Only supports insertion
|
||||
and deletion. Move and rename etc. can be done with a delete
|
||||
followed by an insert. The tabs are numbered starting with 1.
|
||||
@@ -97,4 +98,4 @@ command again, adding --insert or --delete to edit the list.
|
||||
tabs.primitive_insert(course, num - 1, tab_type, name) # -1 as above
|
||||
except ValueError as e:
|
||||
# Cute: translate to CommandError so the CLI error prints nicely.
|
||||
raise CommandError(e)
|
||||
raise CommandError(e) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@@ -32,7 +32,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_id'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u"Invalid course_key: '%s'." % options['course_id'])
|
||||
raise CommandError(u"Invalid course_key: '%s'." % options['course_id']) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().get_course(course_key):
|
||||
raise CommandError(u"Course with %s key not found." % options['course_id'])
|
||||
|
||||
@@ -34,7 +34,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
library_key = CourseKey.from_string(options['library_id'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u'Invalid library ID: "{0}".'.format(options['library_id']))
|
||||
raise CommandError(u'Invalid library ID: "{0}".'.format(options['library_id'])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
if not isinstance(library_key, LibraryLocator):
|
||||
raise CommandError(u'Argument "{0}" is not a library key'.format(options['library_id']))
|
||||
|
||||
@@ -50,7 +50,7 @@ class Command(BaseCommand):
|
||||
# Generate archive using the handy tasks implementation
|
||||
tarball = tasks.create_export_tarball(library, library_key, {}, None)
|
||||
except Exception as e:
|
||||
raise CommandError(u'Failed to export "{0}" with "{1}"'.format(library_key, e))
|
||||
raise CommandError(u'Failed to export "{0}" with "{1}"'.format(library_key, e)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
else:
|
||||
with tarball:
|
||||
# Save generated archive with keyed filename
|
||||
|
||||
@@ -47,9 +47,9 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Unparsable course_id")
|
||||
raise CommandError("Unparsable course_id") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
except IndexError:
|
||||
raise CommandError("Insufficient arguments")
|
||||
raise CommandError("Insufficient arguments") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
filename = options['output']
|
||||
pipe_results = False
|
||||
|
||||
@@ -36,7 +36,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_key'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Invalid course key.")
|
||||
raise CommandError("Invalid course key.") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().get_course(course_key):
|
||||
raise CommandError("Course not found.")
|
||||
|
||||
@@ -6,7 +6,7 @@ Django management command to generate a test course from a course config json
|
||||
import json
|
||||
import logging
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from six import text_type
|
||||
|
||||
@@ -34,9 +34,9 @@ class Command(BaseCommand):
|
||||
try:
|
||||
courses = json.loads(options["courses_json"])["courses"]
|
||||
except ValueError:
|
||||
raise CommandError("Invalid JSON object")
|
||||
raise CommandError("Invalid JSON object") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
except KeyError:
|
||||
raise CommandError("JSON object is missing courses list")
|
||||
raise CommandError("JSON object is missing courses list") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
for course_settings in courses:
|
||||
# Validate course
|
||||
@@ -52,7 +52,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
user = user_from_str(user_email)
|
||||
except User.DoesNotExist:
|
||||
logger.warning(user_email + " user does not exist")
|
||||
logger.warning(user_email + " user does not exist") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
logger.warning("Can't create course, proceeding to next course")
|
||||
continue
|
||||
fields = self._process_course_fields(course_settings["fields"])
|
||||
@@ -102,7 +102,7 @@ class Command(BaseCommand):
|
||||
if field not in all_fields:
|
||||
# field does not exist as a CourseField
|
||||
del fields[field]
|
||||
logger.info(field + "is not a valid CourseField")
|
||||
logger.info(field + "is not a valid CourseField") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
elif fields[field] is None:
|
||||
# field is unset
|
||||
del fields[field]
|
||||
@@ -113,7 +113,7 @@ class Command(BaseCommand):
|
||||
fields[field] = Date().from_json(date_json)
|
||||
logger.info(field + " has been set to " + date_json)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logger.info("The date string could not be parsed for " + field)
|
||||
logger.info("The date string could not be parsed for " + field) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
del fields[field]
|
||||
elif field in course_tab_list_fields:
|
||||
# Generate CourseTabList object from the json value
|
||||
@@ -122,15 +122,15 @@ class Command(BaseCommand):
|
||||
fields[field] = CourseTabList().from_json(course_tab_list_json)
|
||||
logger.info(field + " has been set to " + course_tab_list_json)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logger.info("The course tab list string could not be parsed for " + field)
|
||||
logger.info("The course tab list string could not be parsed for " + field) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
del fields[field]
|
||||
else:
|
||||
# CourseField is valid and has been set
|
||||
logger.info(field + " has been set to " + str(fields[field]))
|
||||
logger.info(field + " has been set to " + str(fields[field])) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
|
||||
for field in all_fields:
|
||||
if field not in fields:
|
||||
logger.info(field + " has not been set")
|
||||
logger.info(field + " has not been set") # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
return fields
|
||||
|
||||
def _course_is_valid(self, course):
|
||||
@@ -147,7 +147,7 @@ class Command(BaseCommand):
|
||||
]
|
||||
for setting in required_course_settings:
|
||||
if setting not in course:
|
||||
logger.warning("Course json is missing " + setting)
|
||||
logger.warning("Course json is missing " + setting) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
is_valid = False
|
||||
|
||||
# Check fields settings
|
||||
@@ -157,7 +157,7 @@ class Command(BaseCommand):
|
||||
if "fields" in course:
|
||||
for setting in required_field_settings:
|
||||
if setting not in course["fields"]:
|
||||
logger.warning("Fields json is missing " + setting)
|
||||
logger.warning("Fields json is missing " + setting) # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
is_valid = False
|
||||
|
||||
return is_valid
|
||||
|
||||
@@ -51,7 +51,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_loc'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError(text_type(git_export_utils.GitExportError.BAD_COURSE))
|
||||
raise CommandError(text_type(git_export_utils.GitExportError.BAD_COURSE)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
try:
|
||||
git_export_utils.export_to_git(
|
||||
@@ -61,4 +61,4 @@ class Command(BaseCommand):
|
||||
options.get('rdir', None)
|
||||
)
|
||||
except git_export_utils.GitExportError as ex:
|
||||
raise CommandError(text_type(ex))
|
||||
raise CommandError(text_type(ex)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@@ -8,7 +8,7 @@ import os
|
||||
import tarfile
|
||||
|
||||
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 SuspiciousOperation
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from lxml import etree
|
||||
@@ -52,7 +52,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
safetar_extractall(tar_file, course_dir.encode('utf-8'))
|
||||
except SuspiciousOperation as exc:
|
||||
raise CommandError(u'\n=== Course import {0}: Unsafe tar file - {1}\n'.format(archive_path, exc.args[0]))
|
||||
raise CommandError(u'\n=== Course import {0}: Unsafe tar file - {1}\n'.format(archive_path, exc.args[0])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
finally:
|
||||
tar_file.close()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ to the new split-Mongo modulestore.
|
||||
"""
|
||||
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
@@ -37,12 +37,12 @@ class Command(BaseCommand):
|
||||
try:
|
||||
course_key = CourseKey.from_string(options['course_key'])
|
||||
except InvalidKeyError:
|
||||
raise CommandError("Invalid location string")
|
||||
raise CommandError("Invalid location string") # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
try:
|
||||
user = user_from_str(options['email'])
|
||||
except User.DoesNotExist:
|
||||
raise CommandError(u"No user found identified by {}".format(options['email']))
|
||||
raise CommandError(u"No user found identified by {}".format(options['email'])) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
return course_key, user.id, options['org'], options['course'], options['run']
|
||||
|
||||
@@ -51,7 +51,7 @@ class Command(BaseCommand):
|
||||
|
||||
migrator = SplitMigrator(
|
||||
source_modulestore=modulestore(),
|
||||
split_modulestore=modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split),
|
||||
split_modulestore=modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split), # lint-amnesty, pylint: disable=protected-access
|
||||
)
|
||||
|
||||
migrator.migrate_mongo_course(course_key, user, org, course, run)
|
||||
|
||||
@@ -47,7 +47,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
result = CourseKey.from_string(raw_value)
|
||||
except InvalidKeyError:
|
||||
raise CommandError(u"Invalid course_key: '%s'." % raw_value)
|
||||
raise CommandError(u"Invalid course_key: '%s'." % raw_value) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not isinstance(result, CourseLocator):
|
||||
raise CommandError(u"Argument {0} is not a course key".format(raw_value))
|
||||
@@ -64,8 +64,7 @@ class Command(BaseCommand):
|
||||
setup_option = options['setup']
|
||||
index_all_courses_option = all_option or setup_option
|
||||
|
||||
if (not len(course_ids) and not index_all_courses_option) or \
|
||||
(len(course_ids) and index_all_courses_option):
|
||||
if (not len(course_ids) and not index_all_courses_option) or (len(course_ids) and index_all_courses_option): # lint-amnesty, pylint: disable=len-as-condition
|
||||
raise CommandError("reindex_course requires one or more <course_id>s OR the --all or --setup flags.")
|
||||
|
||||
store = modulestore()
|
||||
@@ -103,5 +102,5 @@ class Command(BaseCommand):
|
||||
for course_key in course_keys:
|
||||
try:
|
||||
CoursewareSearchIndexer.do_course_reindex(store, course_key)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # lint-amnesty, pylint: disable=broad-except
|
||||
logging.exception('Error indexing course %s due to the error: %s', course_key, exc)
|
||||
|
||||
@@ -5,7 +5,7 @@ integration environment.
|
||||
import logging
|
||||
from textwrap import dedent
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
@@ -37,7 +37,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
user_object = user_from_str(user)
|
||||
except User.DoesNotExist:
|
||||
raise CommandError(u"No user {user} found.".format(user=user))
|
||||
raise CommandError(u"No user {user} found.".format(user=user)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
return user_object
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
@@ -28,7 +28,7 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ExportAllCourses, self).setUp()
|
||||
super(ExportAllCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.content_store = contentstore()
|
||||
# pylint: disable=protected-access
|
||||
self.module_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
@@ -56,7 +56,7 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
# check that there are two assets ['example.txt', '.example.txt'] in contentstore for imported course
|
||||
all_assets, count = self.content_store.get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 2)
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt']))
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
|
||||
# manually add redundant assets (file ".DS_Store" and filename starts with "._")
|
||||
course_filter = course.id.make_asset_key("asset", None)
|
||||
@@ -72,11 +72,11 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
all_assets, count = self.content_store.get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 4)
|
||||
self.assertEqual(
|
||||
set([asset['_id']['name'] for asset in all_assets]),
|
||||
set([asset['_id']['name'] for asset in all_assets]), # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
set([u'.example.txt', u'example.txt', u'._example_test.txt', u'.DS_Store'])
|
||||
)
|
||||
# now call asset_cleanup command and check that there is only two proper assets in contentstore for the course
|
||||
call_command('cleanup_assets')
|
||||
all_assets, count = self.content_store.get_all_content_for_course(course.id)
|
||||
self.assertEqual(count, 2)
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt']))
|
||||
self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) # lint-amnesty, pylint: disable=consider-using-set-comprehension
|
||||
|
||||
@@ -18,8 +18,8 @@ class TestArgParsing(TestCase):
|
||||
"""
|
||||
Tests for parsing arguments for the `create_course` management command
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestArgParsing, self).setUp()
|
||||
def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation
|
||||
super(TestArgParsing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def test_no_args(self):
|
||||
if six.PY2:
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestCourseExport(ModuleStoreTestCase):
|
||||
Test exporting a course
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestCourseExport, self).setUp()
|
||||
super(TestCourseExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Temp directories (temp_dir_1: relative path, temp_dir_2: absolute path)
|
||||
self.temp_dir_1 = mkdtemp()
|
||||
|
||||
@@ -21,8 +21,8 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ExportAllCourses, self).setUp()
|
||||
self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
super(ExportAllCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo) # lint-amnesty, pylint: disable=protected-access
|
||||
self.temp_dir = mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, self.temp_dir)
|
||||
self.first_course = CourseFactory.create(
|
||||
|
||||
@@ -78,7 +78,7 @@ class TestForcePublishModifications(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestForcePublishModifications, self).setUp()
|
||||
super(TestForcePublishModifications, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
|
||||
self.test_user_id = ModuleStoreEnum.UserID.test
|
||||
self.command = Command()
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestGitExport(CourseTestCase):
|
||||
"""
|
||||
Create/reinitialize bare repo and folders needed
|
||||
"""
|
||||
super(TestGitExport, self).setUp()
|
||||
super(TestGitExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
if not os.path.isdir(git_export_utils.GIT_REPO_EXPORT_DIR):
|
||||
os.mkdir(git_export_utils.GIT_REPO_EXPORT_DIR)
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestImport(ModuleStoreTestCase):
|
||||
Unit tests for importing a course from command line
|
||||
"""
|
||||
|
||||
def create_course_xml(self, content_dir, course_id):
|
||||
def create_course_xml(self, content_dir, course_id): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
directory = tempfile.mkdtemp(dir=content_dir)
|
||||
os.makedirs(os.path.join(directory, "course"))
|
||||
with open(os.path.join(directory, "course.xml"), "w+") as f:
|
||||
@@ -37,7 +37,7 @@ class TestImport(ModuleStoreTestCase):
|
||||
"""
|
||||
Build course XML for importing
|
||||
"""
|
||||
super(TestImport, self).setUp()
|
||||
super(TestImport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.content_dir = path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.content_dir)
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ class TestArgParsing(TestCase):
|
||||
"""
|
||||
Tests for parsing arguments for the `migrate_to_split` management command
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestArgParsing, self).setUp()
|
||||
def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation
|
||||
super(TestArgParsing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
def test_no_args(self):
|
||||
"""
|
||||
@@ -64,7 +64,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestMigrateToSplit, self).setUp()
|
||||
super(TestMigrateToSplit, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.course = CourseFactory(default_store=ModuleStoreEnum.Type.mongo)
|
||||
|
||||
def test_user_email(self):
|
||||
@@ -73,11 +73,11 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
"""
|
||||
call_command(
|
||||
"migrate_to_split",
|
||||
str(self.course.id),
|
||||
str(self.course.id), # lint-amnesty, pylint: disable=no-member
|
||||
str(self.user.email),
|
||||
)
|
||||
split_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split)
|
||||
new_key = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run)
|
||||
new_key = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertTrue(
|
||||
split_store.has_course(new_key),
|
||||
"Could not find course"
|
||||
@@ -90,7 +90,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
# lack of error implies success
|
||||
call_command(
|
||||
"migrate_to_split",
|
||||
str(self.course.id),
|
||||
str(self.course.id), # lint-amnesty, pylint: disable=no-member
|
||||
str(self.user.id),
|
||||
)
|
||||
|
||||
@@ -100,7 +100,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
"""
|
||||
call_command(
|
||||
"migrate_to_split",
|
||||
str(self.course.id),
|
||||
str(self.course.id), # lint-amnesty, pylint: disable=no-member
|
||||
str(self.user.id),
|
||||
org="org.dept",
|
||||
course="name",
|
||||
@@ -113,11 +113,11 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
|
||||
# Getting the original course with mongo course_id
|
||||
mongo_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
mongo_locator = mongo_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run)
|
||||
mongo_locator = mongo_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member
|
||||
course_from_mongo = mongo_store.get_course(mongo_locator)
|
||||
self.assertIsNotNone(course_from_mongo)
|
||||
|
||||
# Throws ItemNotFoundError when try to access original course with split course_id
|
||||
split_locator = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run)
|
||||
split_locator = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member
|
||||
with self.assertRaises(ItemNotFoundError):
|
||||
mongo_store.get_course(split_locator)
|
||||
|
||||
@@ -7,7 +7,7 @@ import six
|
||||
from django.core.management import CommandError, call_command
|
||||
from six import text_type
|
||||
|
||||
from cms.djangoapps.contentstore.courseware_index import SearchIndexingError
|
||||
from cms.djangoapps.contentstore.courseware_index import SearchIndexingError # lint-amnesty, pylint: disable=unused-import
|
||||
from cms.djangoapps.contentstore.management.commands.reindex_course import Command as ReindexCommand
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -20,7 +20,7 @@ class TestReindexCourse(ModuleStoreTestCase):
|
||||
""" Tests for course reindex command """
|
||||
def setUp(self):
|
||||
""" Setup method - create courses """
|
||||
super(TestReindexCourse, self).setUp()
|
||||
super(TestReindexCourse, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.store = modulestore()
|
||||
self.first_lib = LibraryFactory.create(
|
||||
org="test", library="lib1", display_name="run1", default_store=ModuleStoreEnum.Type.split
|
||||
|
||||
@@ -20,7 +20,7 @@ class TestReindexLibrary(ModuleStoreTestCase):
|
||||
""" Tests for library reindex command """
|
||||
def setUp(self):
|
||||
""" Setup method - create libraries and courses """
|
||||
super(TestReindexLibrary, self).setUp()
|
||||
super(TestReindexLibrary, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.store = modulestore()
|
||||
self.first_lib = LibraryFactory.create(
|
||||
org="test", library="lib1", display_name="run1", default_store=ModuleStoreEnum.Type.split
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestSyncCoursesCommand(ModuleStoreTestCase):
|
||||
""" Test sync_courses command """
|
||||
|
||||
def setUp(self):
|
||||
super(TestSyncCoursesCommand, self).setUp()
|
||||
super(TestSyncCoursesCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory(username='test', email='test@example.com')
|
||||
self.catalog_course_runs = [
|
||||
@@ -32,9 +32,9 @@ class TestSyncCoursesCommand(ModuleStoreTestCase):
|
||||
|
||||
def _validate_courses(self):
|
||||
for run in self.catalog_course_runs:
|
||||
course_key = CourseKey.from_string(run.get('key'))
|
||||
course_key = CourseKey.from_string(run.get('key')) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertTrue(modulestore().has_course(course_key))
|
||||
CourseOverview.objects.get(id=run.get('key'))
|
||||
CourseOverview.objects.get(id=run.get('key')) # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
def test_courses_sync(self, mock_catalog_course_runs):
|
||||
mock_catalog_course_runs.return_value = self.catalog_course_runs
|
||||
|
||||
@@ -3,7 +3,7 @@ Common methods for cms commands to use
|
||||
"""
|
||||
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
Reference in New Issue
Block a user