当前位置: 首页>>代码示例>>Python>>正文


Python factories.CourseEnrollmentFactory类代码示例

本文整理汇总了Python中student.tests.factories.CourseEnrollmentFactory的典型用法代码示例。如果您正苦于以下问题:Python CourseEnrollmentFactory类的具体用法?Python CourseEnrollmentFactory怎么用?Python CourseEnrollmentFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CourseEnrollmentFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        """
        Create the test data.
        """
        super(CompletionBatchTestCase, self).setUp()
        self.url = reverse('completion_api:v1:completion-batch')

        # Enable the waffle flag for all tests
        self.override_waffle_switch(True)

        # Create course
        self.course = CourseFactory.create(org='TestX', number='101', display_name='Test')
        self.problem = ItemFactory.create(
            parent=self.course,
            category="problem",
            display_name="Test Problem",
        )

        # Create users
        self.staff_user = UserFactory(is_staff=True)
        self.enrolled_user = UserFactory(username=self.ENROLLED_USERNAME)
        self.unenrolled_user = UserFactory(username=self.UNENROLLED_USERNAME)

        # Enrol one user in the course
        CourseEnrollmentFactory.create(user=self.enrolled_user, course_id=self.course.id)

        # Login the enrolled user by for all tests
        self.client = APIClient()
        self.client.force_authenticate(user=self.enrolled_user)
开发者ID:jolyonb,项目名称:edx-platform,代码行数:29,代码来源:test_views.py

示例2: _create_user

 def _create_user(self, username, email=None, is_staff=False, mode="honor"):
     """Creates a user and enrolls them in the test course."""
     if email is None:
         email = InstructorTaskCourseTestCase.get_user_email(username)
     thisuser = UserFactory.create(username=username, email=email, is_staff=is_staff)
     CourseEnrollmentFactory.create(user=thisuser, course_id=self.course.id, mode=mode)
     return thisuser
开发者ID:longmen21,项目名称:edx-platform,代码行数:7,代码来源:test_base.py

示例3: test_data_err_fail

    def test_data_err_fail(self, retry, result):
        """
        Test that celery handles permanent SMTPDataErrors by failing and not retrying.
        """
        self.smtp_server_thread.server.set_errtype(
            "DATA",
            "554 Message rejected: Email address is not verified."
        )

        students = [UserFactory() for _ in xrange(settings.EMAILS_PER_TASK)]
        for student in students:
            CourseEnrollmentFactory.create(user=student, course_id=self.course.id)

        test_email = {
            'action': 'Send email',
            'to_option': 'all',
            'subject': 'test subject for all',
            'message': 'test message for all'
        }
        self.client.post(self.url, test_email)

        # We shouldn't retry when hitting a 5xx error
        self.assertFalse(retry.called)
        # Test that after the rejected email, the rest still successfully send
        ((sent, fail, optouts), _) = result.call_args
        self.assertEquals(optouts, 0)
        self.assertEquals(fail, 1)
        self.assertEquals(sent, settings.EMAILS_PER_TASK - 1)
开发者ID:finneysj,项目名称:edx-platform,代码行数:28,代码来源:test_err_handling.py

示例4: setUp

    def setUp(self):
        super(TestGradebook, self).setUp()

        instructor = AdminFactory.create()
        self.client.login(username=instructor.username, password='test')
        self.users = [UserFactory.create() for _ in xrange(USER_COUNT)]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i, item in enumerate(self.items):
            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=item.location
                )

        self.response = self.client.get(reverse(
            'spoc_gradebook',
            args=(self.course.id.to_deprecated_string(),)
        ))

        self.assertEquals(self.response.status_code, 200)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:26,代码来源:test_spoc_gradebook.py

示例5: setUp

    def setUp(self):
        """
        Setup course structure and create user for split test transformer test.
        """
        super(SplitTestTransformerTestCase, self).setUp()

        # Set up user partitions and groups.
        self.groups = [Group(1, 'Group 1'), Group(2, 'Group 2'), Group(3, 'Group 3')]
        self.split_test_user_partition_id = self.TEST_PARTITION_ID
        self.split_test_user_partition = UserPartition(
            id=self.split_test_user_partition_id,
            name='Split Partition',
            description='This is split partition',
            groups=self.groups,
            scheme=RandomUserPartitionScheme
        )
        self.split_test_user_partition.scheme.name = "random"

        # Build course.
        self.course_hierarchy = self.get_course_hierarchy()
        self.blocks = self.build_course(self.course_hierarchy)
        self.course = self.blocks['course']

        # Enroll user in course.
        CourseEnrollmentFactory.create(user=self.user, course_id=self.course.id, is_active=True)

        self.transformer = UserPartitionTransformer()
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:27,代码来源:test_split_test.py

示例6: setup_students_and_grades

def setup_students_and_grades(context):
    """
    Create students and set their grades.
    :param context:  class reference
    """
    if context.course:
        context.student = student = UserFactory.create()
        CourseEnrollmentFactory.create(user=student, course_id=context.course.id)

        context.student2 = student2 = UserFactory.create()
        CourseEnrollmentFactory.create(user=student2, course_id=context.course.id)

        # create grades for self.student as if they'd submitted the ccx
        for chapter in context.course.get_children():
            for i, section in enumerate(chapter.get_children()):
                for j, problem in enumerate(section.get_children()):
                    # if not problem.visible_to_staff_only:
                    StudentModuleFactory.create(
                        grade=1 if i < j else 0,
                        max_grade=1,
                        student=context.student,
                        course_id=context.course.id,
                        module_state_key=problem.location
                    )

                    StudentModuleFactory.create(
                        grade=1 if i > j else 0,
                        max_grade=1,
                        student=context.student2,
                        course_id=context.course.id,
                        module_state_key=problem.location
                    )
开发者ID:Akif-Vohra,项目名称:edx-platform,代码行数:32,代码来源:test_views.py

示例7: test_resolve_course_enrollments

    def test_resolve_course_enrollments(self):
        """
        Test that the CourseEnrollmentsScopeResolver actually returns all enrollments
        """

        test_user_1 = UserFactory.create(password='test_pass')
        CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id)
        test_user_2 = UserFactory.create(password='test_pass')
        CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id)
        test_user_3 = UserFactory.create(password='test_pass')
        enrollment = CourseEnrollmentFactory(user=test_user_3, course_id=self.course.id)

        # unenroll #3

        enrollment.is_active = False
        enrollment.save()

        resolver = CourseEnrollmentsScopeResolver()

        user_ids = resolver.resolve('course_enrollments', {'course_id': self.course.id}, None)

        # should have first two, but the third should not be present

        self.assertTrue(test_user_1.id in user_ids)
        self.assertTrue(test_user_2.id in user_ids)

        self.assertFalse(test_user_3.id in user_ids)
开发者ID:edx-solutions,项目名称:edx-platform,代码行数:27,代码来源:test_scope_resolver.py

示例8: setUp

    def setUp(self):
        super(TestGetProblemGradeDistribution, self).setUp()

        self.request_factory = RequestFactory()
        self.instructor = AdminFactory.create()
        self.client.login(username=self.instructor.username, password='test')
        self.attempts = 3
        self.users = [
            UserFactory.create(username="metric" + str(__))
            for __ in xrange(USER_COUNT)
        ]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i, item in enumerate(self.items):
            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1 if i < j else 0.5,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=item.location,
                    state=json.dumps({'attempts': self.attempts}),
                )
            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    course_id=self.course.id,
                    module_type='sequential',
                    module_state_key=item.location,
                )
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:31,代码来源:test_dashboard_data.py

示例9: setUp

 def setUp(self):
     super(DiscussionTabTestCase, self).setUp()
     self.course = CourseFactory.create()
     self.enrolled_user = UserFactory.create()
     self.staff_user = AdminFactory.create()
     CourseEnrollmentFactory.create(user=self.enrolled_user, course_id=self.course.id)
     self.unenrolled_user = UserFactory.create()
开发者ID:JudyFox,项目名称:edXMOOC,代码行数:7,代码来源:test_utils.py

示例10: test_double_denied

 def test_double_denied(self):
     ''' First graded problem should show message, second shouldn't '''
     course = self._create_course()
     blocks_dict = course['blocks']
     blocks_dict['graded_1'] = ItemFactory.create(
         parent=blocks_dict['vertical'],
         category='problem',
         graded=True,
         metadata=METADATA,
     )
     blocks_dict['graded_2'] = ItemFactory.create(
         parent=blocks_dict['vertical'],
         category='problem',
         graded=True,
         metadata=METADATA,
     )
     CourseEnrollmentFactory.create(
         user=self.user,
         course_id=course['course'].id,
         mode='audit'
     )
     _assert_block_is_gated(
         block=blocks_dict['graded_1'],
         user=self.user,
         course=course['course'],
         is_gated=True,
         request_factory=self.request_factory,
     )
     _assert_block_is_empty(
         block=blocks_dict['graded_2'],
         user_id=self.user.id,
         course=course['course'],
         request_factory=self.request_factory,
     )
开发者ID:edx,项目名称:edx-platform,代码行数:34,代码来源:test_access.py

示例11: create_course

 def create_course(self, modules_count, module_store, topics):
     """
     Create a course in a specified module store with discussion module and topics
     """
     course = CourseFactory.create(
         org="a",
         course="b",
         run="c",
         start=datetime.now(UTC),
         default_store=module_store,
         discussion_topics=topics
     )
     CourseEnrollmentFactory.create(user=self.user, course_id=course.id)
     course_url = reverse("course_topics", kwargs={"course_id": unicode(course.id)})
     # add some discussion modules
     for i in range(modules_count):
         ItemFactory.create(
             parent_location=course.location,
             category='discussion',
             discussion_id='id_module_{}'.format(i),
             discussion_category='Category {}'.format(i),
             discussion_target='Discussion {}'.format(i),
             publish_item=False,
         )
     return course_url
开发者ID:iivic,项目名称:BoiseStateX,代码行数:25,代码来源:test_views.py

示例12: test_access_masquerade_as_user_with_forum_role

    def test_access_masquerade_as_user_with_forum_role(self, role_name):
        """
        Test that when masquerading as a user with a given forum role you do not lose access to graded content
        """
        staff_user = StaffFactory.create(password=TEST_PASSWORD, course_key=self.course.id)
        CourseEnrollmentFactory.create(
            user=staff_user,
            course_id=self.course.id,
            mode='audit'
        )
        self.client.login(username=staff_user.username, password=TEST_PASSWORD)

        user = UserFactory.create()
        role = RoleFactory(name=role_name, course_id=self.course.id)
        role.users.add(user)

        CourseEnrollmentFactory.create(
            user=user,
            course_id=self.course.id,
            mode='audit'
        )

        self.update_masquerade(username=user.username)

        _assert_block_is_gated(
            block=self.blocks_dict['problem'],
            user=user,
            course=self.course,
            is_gated=False,
            request_factory=self.factory,
        )
开发者ID:edx,项目名称:edx-platform,代码行数:31,代码来源:test_access.py

示例13: test_access_masquerade_as_course_team_users

    def test_access_masquerade_as_course_team_users(self, role_factory):
        """
        Test that when masquerading as members of the course team you do not lose access to graded content
        """
        # There are two types of course team members: instructor and staff
        # they have different privileges, but for the purpose of this test the important thing is that they should both
        # have access to all graded content
        staff_user = StaffFactory.create(password=TEST_PASSWORD, course_key=self.course.id)
        CourseEnrollmentFactory.create(
            user=staff_user,
            course_id=self.course.id,
            mode='audit'
        )
        self.client.login(username=staff_user.username, password=TEST_PASSWORD)

        if role_factory == GlobalStaffFactory:
            user = role_factory.create()
        else:
            user = role_factory.create(course_key=self.course.id)
        self.update_masquerade(username=user.username)

        block = self.blocks_dict['problem']
        block_view_url = reverse('render_xblock', kwargs={'usage_key_string': six.text_type(block.scope_ids.usage_id)})
        response = self.client.get(block_view_url)
        self.assertEquals(response.status_code, 200)
开发者ID:edx,项目名称:edx-platform,代码行数:25,代码来源:test_access.py

示例14: test_access_course_team_users

    def test_access_course_team_users(self, role_factory):
        """
        Test that members of the course team do not lose access to graded content
        """
        # There are two types of course team members: instructor and staff
        # they have different privileges, but for the purpose of this test the important thing is that they should both
        # have access to all graded content
        if role_factory == GlobalStaffFactory:
            user = role_factory.create()
        else:
            user = role_factory.create(course_key=self.course.id)

        CourseEnrollmentFactory.create(
            user=user,
            course_id=self.course.id,
            mode='audit',
        )

        # assert that course team members have access to graded content
        _assert_block_is_gated(
            block=self.blocks_dict['problem'],
            user=user,
            course=self.course,
            is_gated=False,
            request_factory=self.factory,
        )
开发者ID:edx,项目名称:edx-platform,代码行数:26,代码来源:test_access.py

示例15: test_data_err_fail

    def test_data_err_fail(self, retry, result, get_conn):
        """
        Test that celery handles permanent SMTPDataErrors by failing and not retrying.
        """
        # have every fourth email fail due to blacklisting:
        get_conn.return_value.send_messages.side_effect = cycle([SMTPDataError(554, "Email address is blacklisted"),
                                                                 None, None, None])
        students = [UserFactory() for _ in xrange(settings.BULK_EMAIL_EMAILS_PER_TASK)]
        for student in students:
            CourseEnrollmentFactory.create(user=student, course_id=self.course.id)

        test_email = {
            'action': 'Send email',
            'send_to': 'all',
            'subject': 'test subject for all',
            'message': 'test message for all'
        }
        response = self.client.post(self.send_mail_url, test_email)
        self.assertEquals(json.loads(response.content), self.success_content)

        # We shouldn't retry when hitting a 5xx error
        self.assertFalse(retry.called)
        # Test that after the rejected email, the rest still successfully send
        ((_entry_id, _current_task_id, subtask_status), _kwargs) = result.call_args
        self.assertEquals(subtask_status.skipped, 0)
        expected_fails = int((settings.BULK_EMAIL_EMAILS_PER_TASK + 3) / 4.0)
        self.assertEquals(subtask_status.failed, expected_fails)
        self.assertEquals(subtask_status.succeeded, settings.BULK_EMAIL_EMAILS_PER_TASK - expected_fails)
开发者ID:TabEd,项目名称:edx-platform,代码行数:28,代码来源:test_err_handling.py


注:本文中的student.tests.factories.CourseEnrollmentFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。