Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)