Esempio n. 1
0
    def test_get_courses(self, _from_json):
        '''Make sure the course objects loaded properly'''
        courses = self.draft_store.get_courses()

        assert_equals(len(courses), 6)
        course_ids = [course.id for course in courses]

        for course_key in [
                SlashSeparatedCourseKey(*fields) for fields in [
                    ['edX', 'simple', '2012_Fall'],
                    ['edX', 'simple_with_draft', '2012_Fall'],
                    ['edX', 'test_import_course', '2012_Fall'],
                    ['edX', 'test_unicode', '2012_Fall'],
                    ['edX', 'toy', '2012_Fall'],
                    ['guestx', 'foo', 'bar'],
                ]
        ]:
            assert_in(course_key, course_ids)
            course = self.draft_store.get_course(course_key)
            assert_not_none(course)
            assert_true(self.draft_store.has_course(course_key))
            mix_cased = SlashSeparatedCourseKey(course_key.org.upper(),
                                                course_key.course.upper(),
                                                course_key.run.lower())
            assert_false(self.draft_store.has_course(mix_cased))
            assert_true(
                self.draft_store.has_course(mix_cased, ignore_case=True))
Esempio n. 2
0
    def test_get_courses(self, _from_json):
        '''Make sure the course objects loaded properly'''
        courses = self.draft_store.get_courses()

        assert_equals(len(courses), 6)
        course_ids = [course.id for course in courses]

        for course_key in [

            SlashSeparatedCourseKey(*fields)
            for fields in [
                ['edX', 'simple', '2012_Fall'],
                ['edX', 'simple_with_draft', '2012_Fall'],
                ['edX', 'test_import_course', '2012_Fall'],
                ['edX', 'test_unicode', '2012_Fall'],
                ['edX', 'toy', '2012_Fall'],
                ['guestx', 'foo', 'bar'],
            ]
        ]:
            assert_in(course_key, course_ids)
            course = self.draft_store.get_course(course_key)
            assert_not_none(course)
            assert_true(self.draft_store.has_course(course_key))
            mix_cased = SlashSeparatedCourseKey(
                course_key.org.upper(), course_key.course.upper(), course_key.run.lower()
            )
            assert_false(self.draft_store.has_course(mix_cased))
            assert_true(self.draft_store.has_course(mix_cased, ignore_case=True))
Esempio n. 3
0
 def test_unicode_loads(self):
     """
     Test that getting items from the test_unicode course works
     """
     assert_not_none(
         self.draft_store.get_item(
             BlockUsageLocator(CourseLocator('edX', 'test_unicode', '2012_Fall', deprecated=True),
                               'course', '2012_Fall', deprecated=True)),
     )
     # All items with ascii-only filenames should load properly.
     assert_not_none(
         self.draft_store.get_item(
             BlockUsageLocator(CourseLocator('edX', 'test_unicode', '2012_Fall', deprecated=True),
                               'video', 'Welcome', deprecated=True)),
     )
     assert_not_none(
         self.draft_store.get_item(
             BlockUsageLocator(CourseLocator('edX', 'test_unicode', '2012_Fall', deprecated=True),
                               'video', 'Welcome', deprecated=True)),
     )
     assert_not_none(
         self.draft_store.get_item(
             BlockUsageLocator(CourseLocator('edX', 'test_unicode', '2012_Fall', deprecated=True),
                               'chapter', 'Overview', deprecated=True)),
     )
Esempio n. 4
0
 def test_unicode_loads(self):
     """
     Test that getting items from the test_unicode course works
     """
     assert_not_none(self.draft_store.get_item(Location("edX", "test_unicode", "2012_Fall", "course", "2012_Fall")))
     # All items with ascii-only filenames should load properly.
     assert_not_none(self.draft_store.get_item(Location("edX", "test_unicode", "2012_Fall", "video", "Welcome")))
     assert_not_none(self.draft_store.get_item(Location("edX", "test_unicode", "2012_Fall", "video", "Welcome")))
     assert_not_none(self.draft_store.get_item(Location("edX", "test_unicode", "2012_Fall", "chapter", "Overview")))
Esempio n. 5
0
    def test_get_courses(self):
        '''Make sure the course objects loaded properly'''
        courses = self.store.get_courses()
        assert_equals(len(courses), 5)
        course_ids = [course.id for course in courses]
        for course_key in [

            SlashSeparatedCourseKey(*fields)
            for fields in [
                ['edX', 'simple', '2012_Fall'], ['edX', 'simple_with_draft', '2012_Fall'],
                ['edX', 'test_import_course', '2012_Fall'], ['edX', 'test_unicode', '2012_Fall'],
                ['edX', 'toy', '2012_Fall']
            ]
        ]:
            assert_in(course_key, course_ids)
            course = self.store.get_course(course_key)
            assert_not_none(course)
Esempio n. 6
0
    def test_find_one(self):
        assert_not_none(
            self.draft_store._find_one(
                BlockUsageLocator(CourseLocator('edX',
                                                'toy',
                                                '2012_Fall',
                                                deprecated=True),
                                  'course',
                                  '2012_Fall',
                                  deprecated=True)), )

        assert_not_none(
            self.draft_store._find_one(
                BlockUsageLocator(CourseLocator('edX',
                                                'simple',
                                                '2012_Fall',
                                                deprecated=True),
                                  'course',
                                  '2012_Fall',
                                  deprecated=True)), )

        assert_not_none(
            self.draft_store._find_one(
                BlockUsageLocator(CourseLocator('edX',
                                                'toy',
                                                '2012_Fall',
                                                deprecated=True),
                                  'video',
                                  'Welcome',
                                  deprecated=True)), )
Esempio n. 7
0
    def test_get_courses(self):
        '''Make sure the course objects loaded properly'''
        courses = self.draft_store.get_courses()

        # note, the number of courses expected is really
        # 6, but due to a lack of cache flushing between
        # test case runs, we will get back 7.
        # When we fix the caching issue, we should reduce this
        # to 6 and remove the 'treexport_peer_component' course_id
        # from the list below
        assert_equals(len(courses), 7)  # pylint: disable=no-value-for-parameter
        course_ids = [course.id for course in courses]

        for course_key in [

            SlashSeparatedCourseKey(*fields)
            for fields in [
                ['edX', 'simple', '2012_Fall'],
                ['edX', 'simple_with_draft', '2012_Fall'],
                ['edX', 'test_import_course', '2012_Fall'],
                ['edX', 'test_unicode', '2012_Fall'],
                ['edX', 'toy', '2012_Fall'],
                ['guestx', 'foo', 'bar'],
                # This course below is due to a caching issue in the modulestore
                # which is not cleared between test runs. This means
                ['edX', 'treeexport_peer_component', 'export_peer_component'],
            ]
        ]:
            assert_in(course_key, course_ids)
            course = self.draft_store.get_course(course_key)
            assert_not_none(course)
            assert_true(self.draft_store.has_course(course_key))
            mix_cased = SlashSeparatedCourseKey(
                course_key.org.upper(), course_key.course.upper(), course_key.run.lower()
            )
            assert_false(self.draft_store.has_course(mix_cased))
            assert_true(self.draft_store.has_course(mix_cased, ignore_case=True))
Esempio n. 8
0
    def test_get_courses(self, _from_json):
        '''Make sure the course objects loaded properly'''
        courses = self.draft_store.get_courses()

        # note, the number of courses expected is really
        # 6, but due to a lack of cache flushing between
        # test case runs, we will get back 7.
        # When we fix the caching issue, we should reduce this
        # to 6 and remove the 'treexport_peer_component' course_id
        # from the list below
        assert_equals(len(courses), 7)  # pylint: disable=no-value-for-parameter
        course_ids = [course.id for course in courses]

        for course_key in [

            SlashSeparatedCourseKey(*fields)
            for fields in [
                ['edX', 'simple', '2012_Fall'],
                ['edX', 'simple_with_draft', '2012_Fall'],
                ['edX', 'test_import_course', '2012_Fall'],
                ['edX', 'test_unicode', '2012_Fall'],
                ['edX', 'toy', '2012_Fall'],
                ['guestx', 'foo', 'bar'],
                # This course below is due to a caching issue in the modulestore
                # which is not cleared between test runs. This means
                ['edX', 'treeexport_peer_component', 'export_peer_component'],
            ]
        ]:
            assert_in(course_key, course_ids)
            course = self.draft_store.get_course(course_key)
            assert_not_none(course)
            assert_true(self.draft_store.has_course(course_key))
            mix_cased = SlashSeparatedCourseKey(
                course_key.org.upper(), course_key.course.upper(), course_key.run.lower()
            )
            assert_false(self.draft_store.has_course(mix_cased))
            assert_true(self.draft_store.has_course(mix_cased, ignore_case=True))
Esempio n. 9
0
 def test_unicode_loads(self):
     """
     Test that getting items from the test_unicode course works
     """
     assert_not_none(
         self.store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'course', '2012_Fall')),
     )
     # All items with ascii-only filenames should load properly.
     assert_not_none(
         self.store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'video', 'Welcome')),
     )
     assert_not_none(
         self.store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'video', 'Welcome')),
     )
     assert_not_none(
         self.store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'chapter', 'Overview')),
     )
Esempio n. 10
0
 def test_unicode_loads(self):
     """
     Test that getting items from the test_unicode course works
     """
     assert_not_none(
         self.draft_store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'course', '2012_Fall')),
     )
     # All items with ascii-only filenames should load properly.
     assert_not_none(
         self.draft_store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'video', 'Welcome')),
     )
     assert_not_none(
         self.draft_store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'video', 'Welcome')),
     )
     assert_not_none(
         self.draft_store.get_item(Location('edX', 'test_unicode', '2012_Fall', 'chapter', 'Overview')),
     )
Esempio n. 11
0
 def test_get_courses(self):
     """Make sure the course objects loaded properly"""
     courses = self.draft_store.get_courses()
     assert_equals(len(courses), 6)
     course_ids = [course.id for course in courses]
     for course_key in [
         SlashSeparatedCourseKey(*fields)
         for fields in [
             ["edX", "simple", "2012_Fall"],
             ["edX", "simple_with_draft", "2012_Fall"],
             ["edX", "test_import_course", "2012_Fall"],
             ["edX", "test_unicode", "2012_Fall"],
             ["edX", "toy", "2012_Fall"],
         ]
     ]:
         assert_in(course_key, course_ids)
         course = self.draft_store.get_course(course_key)
         assert_not_none(course)
         assert_true(self.draft_store.has_course(course_key))
         mix_cased = SlashSeparatedCourseKey(
             course_key.org.upper(), course_key.course.upper(), course_key.run.lower()
         )
         assert_false(self.draft_store.has_course(mix_cased))
         assert_true(self.draft_store.has_course(mix_cased, ignore_case=True))
Esempio n. 12
0
    def test_find_one(self):
        assert_not_none(
            self.draft_store._find_one(Location('edX', 'toy', '2012_Fall', 'course', '2012_Fall')),
        )

        assert_not_none(
            self.draft_store._find_one(Location('edX', 'simple', '2012_Fall', 'course', '2012_Fall')),
        )

        assert_not_none(
            self.draft_store._find_one(Location('edX', 'toy', '2012_Fall', 'video', 'Welcome')),
        )
Esempio n. 13
0
    def test_loads(self):
        assert_not_none(
            self.draft_store.get_item(Location('edX', 'toy', '2012_Fall', 'course', '2012_Fall'))
        )

        assert_not_none(
            self.draft_store.get_item(Location('edX', 'simple', '2012_Fall', 'course', '2012_Fall')),
        )

        assert_not_none(
            self.draft_store.get_item(Location('edX', 'toy', '2012_Fall', 'video', 'Welcome')),
        )
Esempio n. 14
0
    def test_find_one(self):
        assert_not_none(
            self.draft_store._find_one(Location('edX', 'toy', '2012_Fall', 'course', '2012_Fall')),
        )

        assert_not_none(
            self.draft_store._find_one(Location('edX', 'simple', '2012_Fall', 'course', '2012_Fall')),
        )

        assert_not_none(
            self.draft_store._find_one(Location('edX', 'toy', '2012_Fall', 'video', 'Welcome')),
        )
Esempio n. 15
0
    def test_loads(self):
        assert_not_none(
            self.draft_store.get_item(Location('edX', 'toy', '2012_Fall', 'course', '2012_Fall'))
        )

        assert_not_none(
            self.draft_store.get_item(Location('edX', 'simple', '2012_Fall', 'course', '2012_Fall')),
        )

        assert_not_none(
            self.draft_store.get_item(Location('edX', 'toy', '2012_Fall', 'video', 'Welcome')),
        )
Esempio n. 16
0
    def test_loads(self):
        assert_not_none(
            self.draft_store.get_item(BlockUsageLocator(CourseLocator('edX', 'toy', '2012_Fall', deprecated=True),
                                                        'course', '2012_Fall', deprecated=True))
        )

        assert_not_none(
            self.draft_store.get_item(BlockUsageLocator(CourseLocator('edX', 'simple', '2012_Fall', deprecated=True),
                                                        'course', '2012_Fall', deprecated=True)),
        )

        assert_not_none(
            self.draft_store.get_item(BlockUsageLocator(CourseLocator('edX', 'toy', '2012_Fall', deprecated=True),
                                                        'video', 'Welcome', deprecated=True)),
        )
Esempio n. 17
0
    def test_loads(self):
        assert_not_none(self.draft_store.get_item(Location("edX", "toy", "2012_Fall", "course", "2012_Fall")))

        assert_not_none(self.draft_store.get_item(Location("edX", "simple", "2012_Fall", "course", "2012_Fall")))

        assert_not_none(self.draft_store.get_item(Location("edX", "toy", "2012_Fall", "video", "Welcome")))
Esempio n. 18
0
    def test_find_one(self):
        assert_not_none(self.draft_store._find_one(Location("edX", "toy", "2012_Fall", "course", "2012_Fall")))

        assert_not_none(self.draft_store._find_one(Location("edX", "simple", "2012_Fall", "course", "2012_Fall")))

        assert_not_none(self.draft_store._find_one(Location("edX", "toy", "2012_Fall", "video", "Welcome")))