pylint and pep8 fixes
This commit is contained in:
@@ -451,7 +451,7 @@ class ModuleStoreWrite(ModuleStoreRead):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def delete_item(self, location, user_id=None, delete_all_versions=False, delete_children=False, force=False):
|
||||
def delete_item(self, location, user_id=None, **kwargs):
|
||||
"""
|
||||
Delete an item from persistence. Pass the user's unique id which the persistent store
|
||||
should save with the update if it has that ability.
|
||||
|
||||
@@ -344,7 +344,7 @@ class MixedModuleStore(ModuleStoreWriteBase):
|
||||
parent.children.append(location.url())
|
||||
store.update_item(parent)
|
||||
elif isinstance(store, SplitMongoModuleStore):
|
||||
if isinstance(course_or_parent_loc, basestring): # course_id
|
||||
if isinstance(course_or_parent_loc, basestring): # course_id
|
||||
course_or_parent_loc = loc_mapper().translate_location_to_course_locator(
|
||||
course_or_parent_loc, None
|
||||
)
|
||||
@@ -377,15 +377,15 @@ class MixedModuleStore(ModuleStoreWriteBase):
|
||||
store = self._get_modulestore_for_courseid(course_id)
|
||||
return store.update_item(xblock, user_id)
|
||||
|
||||
def delete_item(self, location, user_id=None):
|
||||
def delete_item(self, location, user_id=None, **kwargs):
|
||||
"""
|
||||
Delete the given item from persistence.
|
||||
Delete the given item from persistence. kwargs allow modulestore specific parameters.
|
||||
"""
|
||||
course_id = self._infer_course_id_try(location)
|
||||
if course_id is None:
|
||||
raise ItemNotFoundError(u"Cannot find modulestore for %s" % location)
|
||||
store = self._get_modulestore_for_courseid(course_id)
|
||||
return store.delete_item(location, user_id=user_id)
|
||||
return store.delete_item(location, user_id=user_id, **kwargs)
|
||||
|
||||
def close_all_connections(self):
|
||||
"""
|
||||
|
||||
@@ -58,8 +58,8 @@ class ItemFactory(SplitFactory):
|
||||
# pylint: disable=W0613
|
||||
@classmethod
|
||||
def _create(cls, target_class, parent_location, category='chapter',
|
||||
user_id='test_user', block_id=None, definition_locator=None, force=False,
|
||||
continue_version=False, **kwargs):
|
||||
user_id='test_user', block_id=None, definition_locator=None, force=False,
|
||||
continue_version=False, **kwargs):
|
||||
"""
|
||||
passes *kwargs* as the new item's field values:
|
||||
|
||||
|
||||
@@ -109,7 +109,11 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
self.addTypeEqualityFunc(BlockUsageLocator, '_compareIgnoreVersion')
|
||||
# define attrs which get set in initdb to quell pylint
|
||||
self.import_chapter_location = self.store = self.fake_location = self.xml_chapter_location = None
|
||||
self.course_locations = []
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def _create_course(self, default, course_id):
|
||||
"""
|
||||
Create a course w/ one item in the persistence store using the given course & item location.
|
||||
@@ -147,8 +151,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
|
||||
return Location(course_dict)
|
||||
|
||||
self.course_locations = {
|
||||
course_id: generate_location(course_id)
|
||||
for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2]
|
||||
course_id: generate_location(course_id)
|
||||
for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2]
|
||||
}
|
||||
self.fake_location = Location('i4x', 'foo', 'bar', 'vertical', 'baz')
|
||||
self.import_chapter_location = self.course_locations[self.MONGO_COURSEID].replace(
|
||||
@@ -184,8 +188,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
|
||||
|
||||
# try negative cases
|
||||
self.assertFalse(self.store.has_item(
|
||||
self.XML_COURSEID1,
|
||||
self.course_locations[self.XML_COURSEID1].replace(name='not_findable', category='problem')
|
||||
self.XML_COURSEID1,
|
||||
self.course_locations[self.XML_COURSEID1].replace(name='not_findable', category='problem')
|
||||
))
|
||||
self.assertFalse(self.store.has_item(self.MONGO_COURSEID, self.fake_location))
|
||||
|
||||
@@ -323,10 +327,12 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
|
||||
self.assertEqual(len(parents), 1)
|
||||
self.assertEqual(parents[0], self.course_locations[self.XML_COURSEID1])
|
||||
|
||||
|
||||
#=============================================================================================================
|
||||
# General utils for not using django settings
|
||||
#=============================================================================================================
|
||||
|
||||
|
||||
def load_function(path):
|
||||
"""
|
||||
Load a function by name.
|
||||
@@ -338,6 +344,7 @@ def load_function(path):
|
||||
return getattr(import_module(module_path), name)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def create_modulestore_instance(engine, doc_store_config, options, i18n_service=None):
|
||||
"""
|
||||
This will return a new instance of a modulestore given an engine and options
|
||||
|
||||
Reference in New Issue
Block a user