def create_and_index_course(self, org_code, short_description): """ Add a course to both database and search. Warning: A ton of gluing here! If this fails, double check both CourseListViewTestCase and MockSearchUrlTest. """ search_course = DemoCourse.get({ 'org': org_code, 'run': '2010', 'number': 'DemoZ', # Using the slash separated course ID bcuz `DemoCourse` isn't updated yet to new locator. 'id': '{org_code}/DemoZ/2010'.format(org_code=org_code), 'content': { 'short_description': short_description, }, }) DemoCourse.index(self.searcher, [search_course]) org, course, run = search_course['id'].split('/') db_course = self.create_course( mobile_available=False, org=org, course=course, run=run, short_description=short_description, ) return db_course
def create_and_index_course(self, org_code, short_description): """ Add a course to both database and search. Warning: A ton of gluing here! If this fails, double check both CourseListViewTestCase and MockSearchUrlTest. """ search_course = DemoCourse.get({ 'org': org_code, 'run': '2010', 'number': 'DemoZ', 'id': f'course-v1:{org_code}+DemoZ+2010', 'content': { 'short_description': short_description, }, }) DemoCourse.index(self.searcher, [search_course]) key = CourseKey.from_string(search_course['id']) db_course = self.create_course( mobile_available=False, org=key.org, course=key.course, run=key.run, ) return db_course