def test_number_mongo_calls(self, store_builder, depth, lazy, access_all_block_fields, num_mongo_calls): request_cache = MemoryCache() with store_builder.build(request_cache=request_cache) as (content_store, modulestore): course_key = self._import_course(content_store, modulestore) # Starting at the root course block, do a breadth-first traversal using # get_children() to retrieve each block's children. with check_mongo_calls(num_mongo_calls): with modulestore.bulk_operations(course_key): start_block = modulestore.get_course(course_key, depth=depth, lazy=lazy) self._traverse_blocks_in_course(start_block, access_all_block_fields)
def test_lazy_when_course_previously_cached(self, store_builder, num_mongo_calls): request_cache = MemoryCache() with store_builder.build(request_cache=request_cache) as (content_store, modulestore): course_key = self._import_course(content_store, modulestore) with check_mongo_calls(num_mongo_calls): with modulestore.bulk_operations(course_key): # assume the course was retrieved earlier course = modulestore.get_course(course_key, depth=0, lazy=True) # and then subsequently retrieved with the lazy and depth=None values course = modulestore.get_item(course.location, depth=None, lazy=False) self._traverse_blocks_in_course(course, access_all_block_fields=True)
def test_number_mongo_calls(self, store_builder, depth, lazy, access_all_block_fields, num_mongo_calls): request_cache = MemoryCache() with store_builder.build(request_cache=request_cache) as (content_store, modulestore): course_key = self._import_course(content_store, modulestore) # Course traversal modeled after the traversal done here: # lms/djangoapps/mobile_api/video_outlines/serializers.py:BlockOutline # Starting at the root course block, do a breadth-first traversal using # get_children() to retrieve each block's children. with check_mongo_calls(num_mongo_calls): with modulestore.bulk_operations(course_key): start_block = modulestore.get_course(course_key, depth=depth, lazy=lazy) self._traverse_blocks_in_course(start_block, access_all_block_fields)
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): self.db_config['collection'] = 'modulestore{0}'.format(uuid.uuid4().hex[:5]) 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.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()