Commit aecc037e by Don Mitchell

pylint and pep8 fixes

parent fc1ca7b3
...@@ -451,7 +451,7 @@ class ModuleStoreWrite(ModuleStoreRead): ...@@ -451,7 +451,7 @@ class ModuleStoreWrite(ModuleStoreRead):
pass pass
@abstractmethod @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 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. should save with the update if it has that ability.
......
...@@ -344,7 +344,7 @@ class MixedModuleStore(ModuleStoreWriteBase): ...@@ -344,7 +344,7 @@ class MixedModuleStore(ModuleStoreWriteBase):
parent.children.append(location.url()) parent.children.append(location.url())
store.update_item(parent) store.update_item(parent)
elif isinstance(store, SplitMongoModuleStore): 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 = loc_mapper().translate_location_to_course_locator(
course_or_parent_loc, None course_or_parent_loc, None
) )
...@@ -377,15 +377,15 @@ class MixedModuleStore(ModuleStoreWriteBase): ...@@ -377,15 +377,15 @@ class MixedModuleStore(ModuleStoreWriteBase):
store = self._get_modulestore_for_courseid(course_id) store = self._get_modulestore_for_courseid(course_id)
return store.update_item(xblock, user_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) course_id = self._infer_course_id_try(location)
if course_id is None: if course_id is None:
raise ItemNotFoundError(u"Cannot find modulestore for %s" % location) raise ItemNotFoundError(u"Cannot find modulestore for %s" % location)
store = self._get_modulestore_for_courseid(course_id) 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): def close_all_connections(self):
""" """
......
...@@ -58,8 +58,8 @@ class ItemFactory(SplitFactory): ...@@ -58,8 +58,8 @@ class ItemFactory(SplitFactory):
# pylint: disable=W0613 # pylint: disable=W0613
@classmethod @classmethod
def _create(cls, target_class, parent_location, category='chapter', def _create(cls, target_class, parent_location, category='chapter',
user_id='test_user', block_id=None, definition_locator=None, force=False, user_id='test_user', block_id=None, definition_locator=None, force=False,
continue_version=False, **kwargs): continue_version=False, **kwargs):
""" """
passes *kwargs* as the new item's field values: passes *kwargs* as the new item's field values:
......
...@@ -109,7 +109,11 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): ...@@ -109,7 +109,11 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
patcher.start() patcher.start()
self.addCleanup(patcher.stop) self.addCleanup(patcher.stop)
self.addTypeEqualityFunc(BlockUsageLocator, '_compareIgnoreVersion') 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): def _create_course(self, default, course_id):
""" """
Create a course w/ one item in the persistence store using the given course & item location. Create a course w/ one item in the persistence store using the given course & item location.
...@@ -147,8 +151,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): ...@@ -147,8 +151,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
return Location(course_dict) return Location(course_dict)
self.course_locations = { self.course_locations = {
course_id: generate_location(course_id) course_id: generate_location(course_id)
for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2] for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2]
} }
self.fake_location = Location('i4x', 'foo', 'bar', 'vertical', 'baz') self.fake_location = Location('i4x', 'foo', 'bar', 'vertical', 'baz')
self.import_chapter_location = self.course_locations[self.MONGO_COURSEID].replace( self.import_chapter_location = self.course_locations[self.MONGO_COURSEID].replace(
...@@ -184,8 +188,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): ...@@ -184,8 +188,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
# try negative cases # try negative cases
self.assertFalse(self.store.has_item( self.assertFalse(self.store.has_item(
self.XML_COURSEID1, self.XML_COURSEID1,
self.course_locations[self.XML_COURSEID1].replace(name='not_findable', category='problem') self.course_locations[self.XML_COURSEID1].replace(name='not_findable', category='problem')
)) ))
self.assertFalse(self.store.has_item(self.MONGO_COURSEID, self.fake_location)) self.assertFalse(self.store.has_item(self.MONGO_COURSEID, self.fake_location))
...@@ -323,10 +327,12 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): ...@@ -323,10 +327,12 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self.assertEqual(len(parents), 1) self.assertEqual(len(parents), 1)
self.assertEqual(parents[0], self.course_locations[self.XML_COURSEID1]) self.assertEqual(parents[0], self.course_locations[self.XML_COURSEID1])
#============================================================================================================= #=============================================================================================================
# General utils for not using django settings # General utils for not using django settings
#============================================================================================================= #=============================================================================================================
def load_function(path): def load_function(path):
""" """
Load a function by name. Load a function by name.
...@@ -338,6 +344,7 @@ def load_function(path): ...@@ -338,6 +344,7 @@ def load_function(path):
return getattr(import_module(module_path), name) return getattr(import_module(module_path), name)
# pylint: disable=unused-argument
def create_modulestore_instance(engine, doc_store_config, options, i18n_service=None): 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 This will return a new instance of a modulestore given an engine and options
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment