def build_with_contentstore(self, contentstore): """ A contextmanager that returns an isolated versioning modulestore, and then deletes all of its data at the end of the context. Args: contentstore: The contentstore that this modulestore should use to store all of its assets. """ doc_store_config = dict(db='modulestore{}'.format( random.randint(0, 10000)), collection='split_module', **COMMON_DOCSTORE_CONFIG) # Set up a temp directory for storing filesystem content created during import fs_root = mkdtemp() modulestore = DraftVersioningModuleStore( contentstore, doc_store_config, fs_root, render_template=repr, xblock_mixins=XBLOCK_MIXINS, ) modulestore.ensure_indexes() try: yield modulestore finally: # Delete the created database modulestore._drop_database() # pylint: disable=protected-access # Delete the created directory on the filesystem rmtree(fs_root, ignore_errors=True)
def setUp(self): super(TestDraftVersioningModuleStore, self).setUp() self.module_store = DraftVersioningModuleStore( contentstore=None, doc_store_config={ 'host': 'localhost', 'db': 'test_xmodule', 'collection': 'modulestore{0}'.format(uuid.uuid4().hex[:5]), }, fs_root='', default_class='xmodule.raw_module.RawDescriptor', render_template=render_to_template_mock, xblock_mixins=(InheritanceMixin, XModuleMixin), ) self.addCleanup(self.module_store._drop_database) SplitModuleTest.bootstrapDB(self.module_store)