def test_discussion_student_view_data(self):
        """
        Tests that course block api returns student_view_data for discussion module
        """
        course_key = ToyCourseFactory.create().id
        course_usage_key = self.store.make_course_usage_key(course_key)
        user = UserFactory.create()
        self.client.login(username=user.username, password='******')
        CourseEnrollmentFactory.create(user=user, course_id=course_key)
        discussion_id = "test_discussion_module_id"
        ItemFactory.create(
            parent_location=course_usage_key,
            category='discussion',
            discussion_id=discussion_id,
            discussion_category='Category discussion',
            discussion_target='Target Discussion',
        )

        url = reverse('blocks_in_block_tree', kwargs={'usage_key_string': unicode(course_usage_key)})
        query_params = {
            'depth': 'all',
            'username': user.username,
            'block_types_filter': 'discussion',
            'student_view_data': 'discussion'
        }
        response = self.client.get(url, query_params)
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.data['root'], unicode(course_usage_key))  # pylint: disable=no-member
        for block_key_string, block_data in response.data['blocks'].iteritems():  # pylint: disable=no-member
            block_key = deserialize_usage_key(block_key_string, course_key)
            self.assertEquals(block_data['id'], block_key_string)
            self.assertEquals(block_data['type'], block_key.block_type)
            self.assertEquals(block_data['display_name'], self.store.get_item(block_key).display_name or '')
            self.assertEqual(block_data['student_view_data'], {"topic_id": discussion_id})
    def setUp(self):
        """
        Regenerate a course with cohort configuration, partition and groups,
        and a student for each test.
        """
        super(TestGetCohortedUserPartition, self).setUp()
        self.course_key = ToyCourseFactory.create().id
        self.course = modulestore().get_course(self.course_key)
        self.student = UserFactory.create()

        self.random_user_partition = UserPartition(
            1,
            'Random Partition',
            'Should not be returned',
            [Group(0, 'Group 0'), Group(1, 'Group 1')],
            scheme=RandomUserPartitionScheme
        )

        self.cohort_user_partition = UserPartition(
            0,
            'Cohort Partition 1',
            'Should be returned',
            [Group(10, 'Group 10'), Group(20, 'Group 20')],
            scheme=CohortPartitionScheme
        )

        self.second_cohort_user_partition = UserPartition(
            2,
            'Cohort Partition 2',
            'Should not be returned',
            [Group(10, 'Group 10'), Group(1, 'Group 1')],
            scheme=CohortPartitionScheme
        )
 def setUp(self):
     super().setUp()
     self.course_key = ToyCourseFactory.create().id
     self.course_usage_key = self.store.make_course_usage_key(
         self.course_key)
     self.block_structure = BlockStructureFactory.create_from_modulestore(
         self.course_usage_key, self.store)
Example #4
0
    def test_parents(self, modulestore_type):
        with self.store.default_store(modulestore_type):

            # setting up our own local course tree here, since it needs to be
            # created with the correct modulestore type.

            if modulestore_type == 'xml':
                course_key = self.store.make_course_key('edX', 'toy', '2012_Fall')
            else:
                course_key = ToyCourseFactory.create(run='2012_Fall_copy').id
            course = self.store.get_course(course_key)

            self.assertIsNone(course.get_parent())

            def recurse(parent):
                """
                Descend the course tree and ensure the result of get_parent()
                is the expected one.
                """
                visited = []
                for child in parent.get_children():
                    self.assertEqual(parent.location, child.get_parent().location)
                    visited.append(child)
                    visited += recurse(child)
                return visited

            visited = recurse(course)
            self.assertEqual(len(visited), 28)
Example #5
0
    def setUpClass(cls):
        super().setUpClass()
        cls.store = modulestore()
        cls.course = ToyCourseFactory.create(
            end=datetime(2028, 1, 1, 1, 1, 1),
            enrollment_start=datetime(2020, 1, 1, 1, 1, 1),
            enrollment_end=datetime(2028, 1, 1, 1, 1, 1),
            emit_signals=True,
            modulestore=cls.store,
            certificate_available_date=_NEXT_WEEK,
            certificates_display_behavior=CertificatesDisplayBehaviors.
            END_WITH_DATE)
        cls.chapter = ItemFactory(parent=cls.course, category='chapter')
        cls.sequence = ItemFactory(parent=cls.chapter,
                                   category='sequential',
                                   display_name='sequence')
        cls.unit = ItemFactory.create(parent=cls.sequence,
                                      category='vertical',
                                      display_name="Vertical")

        cls.user = UserFactory(username='******',
                               email='*****@*****.**',
                               password='******',
                               is_staff=False)
        cls.instructor = UserFactory(username='******',
                                     email='*****@*****.**',
                                     password='******',
                                     is_staff=False)
        CourseInstructorRole(cls.course.id).add_users(cls.instructor)
        cls.url = f'/api/courseware/course/{cls.course.id}'
Example #6
0
 def setUp(self):
     super(TestStudentViewTransformer, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.course_key = ToyCourseFactory.create().id
     self.course_usage_key = self.store.make_course_usage_key(
         self.course_key)
     self.block_structure = BlockStructureFactory.create_from_modulestore(
         self.course_usage_key, self.store)
    def setUp(self):
        """
        Regenerate a course with cohort configuration, partition and groups,
        and a student for each test.
        """
        super(TestGetCohortedUserPartition, self).setUp()
        self.course_key = ToyCourseFactory.create().id
        self.course = modulestore().get_course(self.course_key)
        self.student = UserFactory.create()

        self.random_user_partition = UserPartition(
            1,
            'Random Partition',
            'Should not be returned',
            [Group(0, 'Group 0'), Group(1, 'Group 1')],
            scheme=RandomUserPartitionScheme)

        self.cohort_user_partition = UserPartition(
            0,
            'Cohort Partition 1',
            'Should be returned',
            [Group(10, 'Group 10'),
             Group(20, 'Group 20')],
            scheme=CohortPartitionScheme)

        self.second_cohort_user_partition = UserPartition(
            2,
            'Cohort Partition 2',
            'Should not be returned',
            [Group(10, 'Group 10'), Group(1, 'Group 1')],
            scheme=CohortPartitionScheme)
Example #8
0
    def test_parents(self, modulestore_type):
        with self.store.default_store(modulestore_type):

            # setting up our own local course tree here, since it needs to be
            # created with the correct modulestore type.

            course_key = ToyCourseFactory.create().id
            course = self.store.get_course(course_key)
            self.assertIsNone(course.get_parent())

            def recurse(parent):
                """
                Descend the course tree and ensure the result of get_parent()
                is the expected one.
                """
                visited = []
                for child in parent.get_children():
                    self.assertEqual(parent.location,
                                     child.get_parent().location)
                    visited.append(child)
                    visited += recurse(child)
                return visited

            visited = recurse(course)
            self.assertEqual(len(visited), 28)
Example #9
0
    def setUpClass(cls):
        super().setUpClass()
        cls.store = modulestore()
        cls.course = ToyCourseFactory.create(
            end=datetime(2028, 1, 1, 1, 1, 1),
            enrollment_start=datetime(2020, 1, 1, 1, 1, 1),
            enrollment_end=datetime(2028, 1, 1, 1, 1, 1),
            emit_signals=True,
            modulestore=cls.store,
        )
        cls.chapter = ItemFactory(parent=cls.course, category='chapter')
        cls.sequence = ItemFactory(parent=cls.chapter,
                                   category='sequential',
                                   display_name='sequence')
        cls.unit = ItemFactory.create(parent=cls.sequence,
                                      category='vertical',
                                      display_name="Vertical")

        cls.user = UserFactory(username='******',
                               email=u'*****@*****.**',
                               password='******',
                               is_staff=False)
        cls.instructor = UserFactory(username='******',
                                     email=u'*****@*****.**',
                                     password='******',
                                     is_staff=False)
        CourseInstructorRole(cls.course.id).add_users(cls.instructor)
        cls.url = '/api/courseware/course/{}'.format(cls.course.id)
 def setUpClass(cls):
     super(TestCohortOauth, cls).setUpClass()
     cls.user = UserFactory(username=USERNAME,
                            email=USER_MAIL,
                            password=cls.password)
     cls.staff_user = UserFactory(is_staff=True, password=cls.password)
     cls.course_key = ToyCourseFactory.create().id
     cls.course_str = unicode(cls.course_key)
Example #11
0
    def create_course(**kwargs):
        """
        Create a course for use in test cases
        """

        return ToyCourseFactory.create(
            end=datetime(2015, 9, 19, 18, 0, 0),
            enrollment_start=datetime(2015, 6, 15, 0, 0, 0),
            enrollment_end=datetime(2015, 7, 15, 0, 0, 0),
            **kwargs)
    def setUpClass(cls):
        super(TestBlockSerializerBase, cls).setUpClass()

        cls.course = ToyCourseFactory.create()

        # Hide the html block
        key = cls.course.id.make_usage_key('html', 'secret:toylab')
        cls.html_block = cls.store.get_item(key)
        cls.html_block.visible_to_staff_only = True
        cls.store.update_item(cls.html_block, ModuleStoreEnum.UserID.test)
Example #13
0
    def setUpClass(cls):
        super(TestBlockSerializerBase, cls).setUpClass()

        cls.course = ToyCourseFactory.create()

        # Hide the html block
        key = cls.course.id.make_usage_key('html', 'secret:toylab')
        cls.html_block = cls.store.get_item(key)
        cls.html_block.visible_to_staff_only = True
        cls.store.update_item(cls.html_block, ModuleStoreEnum.UserID.test)
Example #14
0
    def create_course(**kwargs):
        """
        Create a course for use in test cases
        """

        return ToyCourseFactory.create(
            end=datetime(2015, 9, 19, 18, 0, 0),
            enrollment_start=datetime(2015, 6, 15, 0, 0, 0),
            enrollment_end=datetime(2015, 7, 15, 0, 0, 0),
            **kwargs
        )
Example #15
0
 def setUpClass(cls):
     """
     Set up a course for use in these tests
     """
     super().setUpClass()
     with cls.store.default_store(ModuleStoreEnum.Type.split):
         cls.course = ToyCourseFactory.create(modulestore=cls.store)
     assert str(cls.course.id).startswith(
         "course-v1:"), "This test is for split mongo course exports only"
     cls.unit_key = cls.course.id.make_usage_key('vertical',
                                                 'vertical_test')
Example #16
0
    def setup_course(cls):
        """
        Create a sample course
        """
        cls.course_key = ToyCourseFactory.create().id

        cls.non_orphaned_block_usage_keys = set(
            unicode(item.location)
            for item in cls.store.get_items(cls.course_key)
            # remove all orphaned items in the course, except for the root 'course' block
            if cls.store.get_parent_location(item.location) or item.category == 'course'
        )
Example #17
0
    def setup_course(cls):
        """
        Create a sample course
        """
        cls.course_key = ToyCourseFactory.create().id

        cls.non_orphaned_block_usage_keys = set(
            unicode(item.location)
            for item in cls.store.get_items(cls.course_key)
            # remove all orphaned items in the course, except for the root 'course' block
            if cls.store.get_parent_location(item.location)
            or item.category == 'course')
 def setUp(self):
     super(TestOverrideDataTransformer, self).setUp()
     self.course_key = ToyCourseFactory.create().id
     self.course_usage_key = self.store.make_course_usage_key(self.course_key)
     self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store)
     self.course = course = modulestore().get_course(self.course_key)
     section = course.get_children()[0]
     subsection = section.get_children()[0]
     self.block = self.store.create_child(
         self.learner.id, subsection.location, 'html', 'new_component'
     )
     CourseEnrollmentFactory.create(user=self.learner, course_id=self.course_key, is_active=True)
    def setUpClass(cls):
        super(TestBlocksView, cls).setUpClass()

        # create a toy course
        cls.course_key = ToyCourseFactory.create().id
        cls.course_usage_key = cls.store.make_course_usage_key(cls.course_key)
        cls.non_orphaned_block_usage_keys = set(
            unicode(item.location)
            for item in cls.store.get_items(cls.course_key)
            # remove all orphaned items in the course, except for the root 'course' block
            if cls.store.get_parent_location(item.location)
            or item.category == 'course')
Example #20
0
    def setUpClass(cls):
        super(TestBlocksView, cls).setUpClass()

        # create a toy course
        cls.course_key = ToyCourseFactory.create().id
        cls.course_usage_key = cls.store.make_course_usage_key(cls.course_key)
        cls.non_orphaned_block_usage_keys = set(
            unicode(item.location)
            for item in cls.store.get_items(cls.course_key)
            # remove all orphaned items in the course, except for the root 'course' block
            if cls.store.get_parent_location(item.location) or item.category == 'course'
        )
Example #21
0
    def setUp(self):
        super(RoleClassTestCase, self).setUp()

        # For course ID, syntax edx/classname/classdate is important
        # because xmodel.course_module.id_to_location looks for a string to split

        self.course_id = ToyCourseFactory.create().id
        self.student_role = models.Role.objects.get_or_create(name="Student", course_id=self.course_id)[0]
        self.student_role.add_permission("delete_thread")
        self.student_2_role = models.Role.objects.get_or_create(name="Student", course_id=self.course_id)[0]
        self.TA_role = models.Role.objects.get_or_create(name="Community TA", course_id=self.course_id)[0]
        self.course_id_2 = CourseKey.from_string("edX/6.002x/2012_Fall")
        self.TA_role_2 = models.Role.objects.get_or_create(name="Community TA", course_id=self.course_id_2)[0]
    def setUp(self):
        """
        Regenerate a test course and cohorts for each test
        """
        super(TestCohortsAndPartitionGroups, self).setUp()

        self.test_course_key = ToyCourseFactory.create().id
        self.course = modulestore().get_course(self.test_course_key)

        self.first_cohort = CohortFactory(course_id=self.course.id, name="FirstCohort")
        self.second_cohort = CohortFactory(course_id=self.course.id, name="SecondCohort")

        self.partition_id = 1
        self.group1_id = 10
        self.group2_id = 20
Example #23
0
    def setUp(self):
        """
        Regenerate a test course and cohorts for each test
        """
        super(TestCohortsAndPartitionGroups, self).setUp()

        self.test_course_key = ToyCourseFactory.create().id
        self.course = modulestore().get_course(self.test_course_key)

        self.first_cohort = CohortFactory(course_id=self.course.id, name="FirstCohort")
        self.second_cohort = CohortFactory(course_id=self.course.id, name="SecondCohort")

        self.partition_id = 1
        self.group1_id = 10
        self.group2_id = 20
Example #24
0
 def setUpClass(cls):
     super().setUpClass()
     cls.store = modulestore()
     cls.course = ToyCourseFactory.create(
         end=datetime(2028, 1, 1, 1, 1, 1),
         enrollment_start=datetime(2020, 1, 1, 1, 1, 1),
         enrollment_end=datetime(2028, 1, 1, 1, 1, 1),
         emit_signals=True,
         modulestore=cls.store,
     )
     cls.user = UserFactory(username='******',
                            email=u'*****@*****.**',
                            password='******',
                            is_staff=False)
     cls.url = '/api/courseware/course/{}'.format(cls.course.id)
Example #25
0
    def setUpClass(cls):
        super(TestBlocksView, cls).setUpClass()

        # create a toy course
        cls.course = ToyCourseFactory.create(
            modulestore=cls.store,
            due=datetime(3013, 9, 18, 11, 30, 00),
        )
        cls.course_key = cls.course.id
        cls.course_usage_key = cls.store.make_course_usage_key(cls.course_key)

        cls.non_orphaned_block_usage_keys = set(
            str(item.location) for item in cls.store.get_items(cls.course_key)
            # remove all orphaned items in the course, except for the root 'course' block
            if cls.store.get_parent_location(item.location)
            or item.category == 'course')
    def setUp(self):
        """
        Regenerate a course with cohort configuration, partition and groups,
        and a student for each test.
        """
        super(TestCohortPartitionScheme, self).setUp()

        self.course_key = ToyCourseFactory.create().id
        self.course = modulestore().get_course(self.course_key)
        config_course_cohorts(self.course, is_cohorted=True)

        self.groups = [Group(10, "Group 10"), Group(20, "Group 20")]
        self.user_partition = UserPartition(
            0, "Test Partition", "for testing purposes", self.groups, scheme=CohortPartitionScheme
        )
        self.student = UserFactory.create()
Example #27
0
    def test_permissions_query_load(self):
        """
        Tests that the permissions queries are cached when rendering numerous discussion XBlocks.
        """
        user = UserFactory.create()
        course = ToyCourseFactory.create()
        course_key = course.id
        course_usage_key = self.store.make_course_usage_key(course_key)
        discussions = []

        for counter in range(5):
            discussion_id = 'test_discussion_{}'.format(counter)
            discussions.append(
                ItemFactory.create(
                    parent_location=course_usage_key,
                    category='discussion',
                    discussion_id=discussion_id,
                    discussion_category='Category discussion',
                    discussion_target='Target Discussion',
                ))

        # 3 queries are required to do first discussion xblock render:
        # * django_comment_client_role
        # * django_comment_client_permission
        # * lms_xblock_xblockasidesconfig
        num_queries = 3
        for discussion in discussions:
            discussion_xblock = get_module_for_descriptor_internal(
                user=user,
                descriptor=discussion,
                student_data=mock.Mock(name='student_data'),
                course_id=course.id,
                track_function=mock.Mock(name='track_function'),
                xqueue_callback_url_prefix=mock.Mock(
                    name='xqueue_callback_url_prefix'),
                request_token='request_token',
            )
            with self.assertNumQueries(num_queries):
                fragment = discussion_xblock.render('student_view')

            # Permissions are cached, so no queries required for subsequent renders
            num_queries = 0

            html = fragment.content
            self.assertIn('data-user-create-comment="false"', html)
            self.assertIn('data-user-create-subcomment="false"', html)
    def test_permissions_query_load(self):
        """
        Tests that the permissions queries are cached when rendering numerous discussion XBlocks.
        """
        user = UserFactory.create()
        course = ToyCourseFactory.create()
        course_key = course.id
        course_usage_key = self.store.make_course_usage_key(course_key)
        discussions = []

        for counter in range(5):
            discussion_id = "test_discussion_{}".format(counter)
            discussions.append(
                ItemFactory.create(
                    parent_location=course_usage_key,
                    category="discussion",
                    discussion_id=discussion_id,
                    discussion_category="Category discussion",
                    discussion_target="Target Discussion",
                )
            )

        # 3 queries are required to do first discussion xblock render:
        # * django_comment_client_role
        # * django_comment_client_permission
        # * lms_xblock_xblockasidesconfig
        num_queries = 3
        for discussion in discussions:
            discussion_xblock = get_module_for_descriptor_internal(
                user=user,
                descriptor=discussion,
                student_data=mock.Mock(name="student_data"),
                course_id=course.id,
                track_function=mock.Mock(name="track_function"),
                xqueue_callback_url_prefix=mock.Mock(name="xqueue_callback_url_prefix"),
                request_token="request_token",
            )
            with self.assertNumQueries(num_queries):
                fragment = discussion_xblock.render("student_view")

            # Permissions are cached, so no queries required for subsequent renders
            num_queries = 0

            html = fragment.content
            self.assertIn('data-user-create-comment="false"', html)
            self.assertIn('data-user-create-subcomment="false"', html)
Example #29
0
    def setUpClass(cls):
        super(TestBlocksView, cls).setUpClass()

        # create a toy course
        cls.course = ToyCourseFactory.create(
            modulestore=cls.store,
            due=datetime(3013, 9, 18, 11, 30, 00),
        )
        cls.course_key = cls.course.id
        cls.course_usage_key = cls.store.make_course_usage_key(cls.course_key)

        cls.non_orphaned_block_usage_keys = set(
            six.text_type(item.location)
            for item in cls.store.get_items(cls.course_key)
            # remove all orphaned items in the course, except for the root 'course' block
            if cls.store.get_parent_location(item.location) or item.category == 'course'
        )
Example #30
0
    def setUp(self):
        super(RoleClassTestCase, self).setUp()

        # For course ID, syntax edx/classname/classdate is important
        # because xmodel.course_module.id_to_location looks for a string to split

        self.course_id = ToyCourseFactory.create().id
        self.student_role = models.Role.objects.get_or_create(name="Student",
                                                              course_id=self.course_id)[0]
        self.student_role.add_permission("delete_thread")
        self.student_2_role = models.Role.objects.get_or_create(name="Student",
                                                                course_id=self.course_id)[0]
        self.TA_role = models.Role.objects.get_or_create(name="Community TA",
                                                         course_id=self.course_id)[0]
        self.course_id_2 = CourseKey.from_string("edX/6.002x/2012_Fall")
        self.TA_role_2 = models.Role.objects.get_or_create(name="Community TA",
                                                           course_id=self.course_id_2)[0]
    def setUp(self):
        """
        Regenerate a course with cohort configuration, partition and groups,
        and a student for each test.
        """
        super(TestCohortPartitionScheme, self).setUp()

        self.course_key = ToyCourseFactory.create().id
        self.course = modulestore().get_course(self.course_key)
        config_course_cohorts(self.course, is_cohorted=True)

        self.groups = [Group(10, 'Group 10'), Group(20, 'Group 20')]
        self.user_partition = UserPartition(0,
                                            'Test Partition',
                                            'for testing purposes',
                                            self.groups,
                                            scheme=CohortPartitionScheme)
        self.student = UserFactory.create()
Example #32
0
 def setUpClass(cls):
     """
     Set up a user, course, and discussion XBlock for use by tests.
     """
     super(TestXBlockInCourse, cls).setUpClass()
     cls.user = UserFactory.create()
     cls.course = ToyCourseFactory.create()
     cls.course_key = cls.course.id
     cls.course_usage_key = cls.store.make_course_usage_key(cls.course_key)
     cls.discussion_id = "test_discussion_xblock_id"
     cls.discussion = ItemFactory.create(
         parent_location=cls.course_usage_key,
         category='discussion',
         discussion_id=cls.discussion_id,
         discussion_category='Category discussion',
         discussion_target='Target Discussion',
     )
     CourseEnrollmentFactory.create(user=cls.user, course_id=cls.course_key)
    def test_discussion_student_view_data(self):
        """
        Tests that course block api returns student_view_data for discussion module
        """
        course_key = ToyCourseFactory.create().id
        course_usage_key = self.store.make_course_usage_key(course_key)
        user = UserFactory.create()
        self.client.login(username=user.username, password='******')
        CourseEnrollmentFactory.create(user=user, course_id=course_key)
        discussion_id = "test_discussion_module_id"
        ItemFactory.create(
            parent_location=course_usage_key,
            category='discussion',
            discussion_id=discussion_id,
            discussion_category='Category discussion',
            discussion_target='Target Discussion',
        )

        url = reverse('blocks_in_block_tree',
                      kwargs={'usage_key_string': unicode(course_usage_key)})
        query_params = {
            'depth': 'all',
            'username': user.username,
            'block_types_filter': 'discussion',
            'student_view_data': 'discussion'
        }
        response = self.client.get(url, query_params)
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.data['root'], unicode(course_usage_key))  # pylint: disable=no-member
        for block_key_string, block_data in response.data['blocks'].iteritems(
        ):  # pylint: disable=no-member
            block_key = deserialize_usage_key(block_key_string, course_key)
            self.assertEquals(block_data['id'], block_key_string)
            self.assertEquals(block_data['type'], block_key.block_type)
            self.assertEquals(
                block_data['display_name'],
                self.store.get_item(block_key).display_name or '')
            self.assertEqual(block_data['student_view_data'],
                             {"topic_id": discussion_id})
Example #34
0
    def setup_course_metadata(self, request):
        """
        Setup course metadata and related database entries for provider state setup.
        """
        course_key = CourseKey.from_string(self.COURSE_KEY)

        self.clean_db(request.user, course_key)
        self.start_modulestore_isolation()

        demo_course = ToyCourseFactory.create(
            org=course_key.org,
            course=course_key.course,
            run=course_key.run,
            display_name="Demonstration Course",
            modulestore=self.store,
            start=datetime(2024, 1, 1, 1, 1, 1),
            end=datetime(2028, 1, 1, 1, 1, 1),
            enrollment_start=datetime(2020, 1, 1, 1, 1, 1),
            enrollment_end=datetime(2028, 1, 1, 1, 1, 1),
            license="all-rights-reserved",
        )

        CourseModeFactory(
            course_id=demo_course.id,
            mode_slug=CourseMode.AUDIT,
        )

        CourseModeFactory(
            course_id=demo_course.id,
            mode_slug=CourseMode.VERIFIED,
            expiration_datetime=datetime(3028, 1, 1),
            min_price=149,
            sku='ABCD1234',
        )

        CourseEnrollment.enroll(request.user, demo_course.id, CourseMode.AUDIT)
        CourseDurationLimitConfig.objects.create(enabled=True,
                                                 enabled_as_of=datetime(
                                                     2018, 1, 1))
 def setUp(self):
     """
     Make sure that course is reloaded every time--clear out the modulestore.
     """
     super(TestCohorts, self).setUp()
     self.toy_course_key = ToyCourseFactory.create().id
 def setUpClass(cls):
     super(ToyCourseCompletionTestCase, cls).setUpClass()
     cls.course = ToyCourseFactory.create()
Example #37
0
 def setUp(self):
     super(TestMongoCoursesLoad, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.setup_user()
     self.toy_course_key = ToyCourseFactory.create().id
Example #38
0
 def setUp(self):
     """
     Make sure that course is reloaded every time--clear out the modulestore.
     """
     super(TestCohorts, self).setUp()
     self.toy_course_key = ToyCourseFactory.create().id
Example #39
0
 def setUp(self):
     super(TestMongoCoursesLoad, self).setUp()
     self.setup_user()
     self.toy_course_key = ToyCourseFactory.create().id
Example #40
0
 def setUp(self):
     super().setUp()
     self.setup_user()
     self.toy_course_key = ToyCourseFactory.create().id
 def setUp(self):
     super(TestStudentViewTransformer, self).setUp()
     self.course_key = ToyCourseFactory.create().id
     self.course_usage_key = self.store.make_course_usage_key(self.course_key)
     self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store)
Example #42
0
    def setUpClass(cls):
        super(TestBlockSerializerBase, cls).setUpClass()

        cls.course = ToyCourseFactory.create()
    def setUpClass(cls):
        super(TestBlockSerializerBase, cls).setUpClass()

        cls.course = ToyCourseFactory.create()
Example #44
0
 def setUpClass(cls):
     super(CompletionViewTestCase, cls).setUpClass()
     cls.course = ToyCourseFactory.create()
     cls.otherOrgCourse = ToyCourseFactory.create(org='otherOrg')
     cls.futureCourse = ToyCourseFactory.create(org='futureOrg', start=datetime.utcnow() + timedelta(weeks=1))
Example #45
0
 def setUp(self):
     """
     Make sure that course is reloaded every time--clear out the modulestore.
     """
     super(TestCohorts, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.toy_course_key = ToyCourseFactory.create().id
Example #46
0
 def setUp(self):
     super(TestMongoCoursesLoad, self).setUp()
     self.setup_user()
     self.toy_course_key = ToyCourseFactory.create().id
 def setUpClass(cls):
     super(TestCohortOauth, cls).setUpClass()
     cls.user = UserFactory(username=USERNAME, email=USER_MAIL, password=cls.password)
     cls.staff_user = UserFactory(is_staff=True, password=cls.password)
     cls.course_key = ToyCourseFactory.create().id
     cls.course_str = unicode(cls.course_key)