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', # 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
def setUp(self): super(CourseListSearchViewTest, self).setUp() DemoCourse.reset_count() self.searcher.destroy() self.courses = [ self.create_and_index_course('OrgA', 'Find this one with the right parameter'), self.create_and_index_course('OrgB', 'Find this one with another parameter'), self.create_and_index_course('OrgC', 'This course has a unique search term'), ] self.url = reverse('course-list') self.staff_user = self.create_user(username='******', is_staff=True) self.honor_user = self.create_user(username='******', is_staff=False)
def setUp(self): super(CourseListSearchViewTest, self).setUp() DemoCourse.reset_count() self.searcher.destroy() self.courses = [ self.create_and_index_course('OrgA', 'Find this one with the right parameter'), self.create_and_index_course('OrgB', 'Find this one with another parameter'), self.create_and_index_course('OrgC', 'This course has a unique search term'), ] self.url = reverse('course-list') self.staff_user = self.create_user(username='******', is_staff=True) self.honor_user = self.create_user(username='******', is_staff=False)