def test_create_item_from_course_id(self, default_ms): """ Test code paths missed by the above: * passing an old-style course_id which has a loc map to split's create_item """ self.initdb(default_ms) # create loc_map entry loc_mapper().translate_location(self.MONGO_COURSEID, generate_location(self.MONGO_COURSEID)) orphan = self.store.create_item(self.MONGO_COURSEID, 'problem', block_id='orphan') self.assertEqual( orphan.location.version_agnostic().as_course_locator(), self.course_locations[self.MONGO_COURSEID].as_course_locator() )
def initdb(self, default): """ Initialize the database and create one test course in it """ # set the default modulestore self.options['stores']['default'] = self.options['stores'][default] self.store = MixedModuleStore(**self.options) self.addCleanup(self.store.close_all_connections) # convert to CourseKeys self.course_locations = { course_id: SlashSeparatedCourseKey.from_deprecated_string(course_id) for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2] } # and then to the root UsageKey self.course_locations = { course_id: course_key.make_usage_key('course', course_key.run) for course_id, course_key in self.course_locations.iteritems() # pylint: disable=maybe-no-member } self.fake_location = Location('foo', 'bar', 'slowly', 'vertical', 'baz') self.import_chapter_location = self.course_locations[ self.MONGO_COURSEID].replace(category='chapter', name='Overview') self.xml_chapter_location = self.course_locations[ self.XML_COURSEID1].replace(category='chapter', name='Overview') # get Locators and set up the loc mapper if app is Locator based if default == 'split': self.fake_location = loc_mapper().translate_location( self.fake_location) self._create_course( default, self.course_locations[self.MONGO_COURSEID].course_key)
def initdb(self, default): """ Initialize the database and create one test course in it """ # set the default modulestore self.options['stores']['default'] = self.options['stores'][default] self.store = MixedModuleStore(**self.options) self.addCleanup(self.store.close_all_connections) self.course_locations = { 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( category='chapter', name='Overview' ) self.xml_chapter_location = self.course_locations[self.XML_COURSEID1].replace( category='chapter', name='Overview' ) # get Locators and set up the loc mapper if app is Locator based if default == 'split': self.fake_location = loc_mapper().translate_location('foo/bar/2012_Fall', self.fake_location) self._create_course(default, self.MONGO_COURSEID)
def initdb(self, default): """ Initialize the database and create one test course in it """ # set the default modulestore self.options['stores']['default'] = self.options['stores'][default] self.store = MixedModuleStore(**self.options) self.addCleanup(self.store.close_all_connections) # convert to CourseKeys self.course_locations = { course_id: SlashSeparatedCourseKey.from_deprecated_string(course_id) for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2] } # and then to the root UsageKey self.course_locations = { course_id: course_key.make_usage_key('course', course_key.run) for course_id, course_key in self.course_locations.iteritems() # pylint: disable=maybe-no-member } self.fake_location = Location('foo', 'bar', 'slowly', 'vertical', 'baz') self.import_chapter_location = self.course_locations[self.MONGO_COURSEID].replace( category='chapter', name='Overview' ) self.xml_chapter_location = self.course_locations[self.XML_COURSEID1].replace( category='chapter', name='Overview' ) # get Locators and set up the loc mapper if app is Locator based if default == 'split': self.fake_location = loc_mapper().translate_location(self.fake_location) self._create_course(default, self.course_locations[self.MONGO_COURSEID].course_key)