def setUp(self):
     super(TestMigration, self).setUp()
     self.loc_mapper = LocMapperStore(**self.db_config)
     self.old_mongo = MongoModuleStore(**self.modulestore_options)
     self.draft_mongo = DraftModuleStore(**self.modulestore_options)
     self.split_mongo = SplitMongoModuleStore(
         loc_mapper=self.loc_mapper, **self.modulestore_options
     )
     self.migrator = SplitMigrator(self.split_mongo, self.old_mongo, self.draft_mongo, self.loc_mapper)
     self.course_location = None
     self.create_source_course()
Esempio n. 2
0
 def setUp(self):
     self.user_id = random.getrandbits(32)
     super(SplitWMongoCourseBootstrapper, self).setUp()
     self.split_mongo = SplitMongoModuleStore(None, self.db_config,
                                              **self.modulestore_options)
     self.addCleanup(self.split_mongo._drop_database)  # pylint: disable=protected-access
     self.draft_mongo = DraftMongoModuleStore(
         None,
         self.db_config,
         branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred,
         metadata_inheritance_cache_subsystem=MemoryCache(),
         **self.modulestore_options)
     self.addCleanup(self.draft_mongo._drop_database)  # pylint: disable=protected-access
     self.old_course_key = None
     self.runtime = None
     self._create_course()
 def setUp(self):
     super(TestMigration, self).setUp()
     # pylint: disable=W0142
     self.loc_mapper = LocMapperStore(test_location_mapper.TrivialCache(),
                                      **self.db_config)
     self.old_mongo = MongoModuleStore(self.db_config,
                                       **self.modulestore_options)
     self.draft_mongo = DraftModuleStore(self.db_config,
                                         **self.modulestore_options)
     self.split_mongo = SplitMongoModuleStore(
         doc_store_config=self.db_config,
         loc_mapper=self.loc_mapper,
         **self.modulestore_options)
     self.migrator = SplitMigrator(self.split_mongo, self.old_mongo,
                                   self.draft_mongo, self.loc_mapper)
     self.course_location = None
     self.create_source_course()
    def setUp(self):
        self.db_config['collection'] = 'modulestore{0}'.format(uuid.uuid4().hex[:5])

        self.userid = random.getrandbits(32)
        super(SplitWMongoCourseBoostrapper, self).setUp()
        self.split_mongo = SplitMongoModuleStore(
            self.db_config,
            **self.modulestore_options
        )
        self.addCleanup(self.split_mongo.db.connection.close)
        self.addCleanup(self.tear_down_split)
        self.old_mongo = MongoModuleStore(self.db_config, **self.modulestore_options)
        self.draft_mongo = DraftMongoModuleStore(self.db_config, **self.modulestore_options)
        self.addCleanup(self.tear_down_mongo)
        self.old_course_key = None
        self.runtime = None
        self._create_course()
Esempio n. 5
0
 def setUp(self):
     super(TestMigration, self).setUp()
     noop_cache = mock.Mock(spec=['get', 'set_many'])
     noop_cache.configure_mock(**{'get.return_value': None})
     # pylint: disable=W0142
     self.loc_mapper = LocMapperStore(noop_cache, **self.db_config)
     self.old_mongo = MongoModuleStore(self.db_config,
                                       **self.modulestore_options)
     self.draft_mongo = DraftModuleStore(self.db_config,
                                         **self.modulestore_options)
     self.split_mongo = SplitMongoModuleStore(
         doc_store_config=self.db_config,
         loc_mapper=self.loc_mapper,
         **self.modulestore_options)
     self.migrator = SplitMigrator(self.split_mongo, self.old_mongo,
                                   self.draft_mongo, self.loc_mapper)
     self.course_location = None
     self.create_source_course()
Esempio n. 6
0
    def setUp(self):
        self.db_config['collection'] = 'modulestore{0}'.format(
            uuid.uuid4().hex[:5])

        self.user_id = random.getrandbits(32)
        super(SplitWMongoCourseBoostrapper, self).setUp()
        self.split_mongo = SplitMongoModuleStore(None, self.db_config,
                                                 **self.modulestore_options)
        self.addCleanup(self.split_mongo.db.connection.close)
        self.addCleanup(self.tear_down_split)
        self.draft_mongo = DraftMongoModuleStore(
            None,
            self.db_config,
            branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred,
            metadata_inheritance_cache_subsystem=MemoryCache(),
            **self.modulestore_options)
        self.addCleanup(self.tear_down_mongo)
        self.old_course_key = None
        self.runtime = None
        self._create_course()
    def build(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.
        """
        # pylint: disable=unreachable
        raise SkipTest(
            "DraftVersioningModuleStore doesn't yet support the same interface as the rest of the modulestores"
        )
        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 = SplitMongoModuleStore(
            contentstore,
            doc_store_config,
            fs_root,
            render_template=repr,
        )

        try:
            yield modulestore
        finally:
            # Delete the created database
            db = modulestore.db
            db.connection.drop_database(db)
            db.connection.close()

            # Delete the created directory on the filesystem
            rmtree(fs_root)