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


Python CourseEnrollmentFactory.create方法代码示例

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


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

示例1: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    def setUp(self):
        super(TestBlockListGetForm, self).setUp()

        self.student = UserFactory.create()
        self.student2 = UserFactory.create()
        self.staff = UserFactory.create(is_staff=True)

        CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
        CourseEnrollmentFactory.create(user=self.student2, course_id=self.course.id)

        usage_key = self.course.location
        self.initial = {"requesting_user": self.student}
        self.form_data = QueryDict(
            urlencode({"username": self.student.username, "usage_key": unicode(usage_key)}), mutable=True
        )
        self.cleaned_data = {
            "all_blocks": None,
            "block_counts": set(),
            "depth": 0,
            "nav_depth": None,
            "return_type": "dict",
            "requested_fields": {"display_name", "type"},
            "student_view_data": set(),
            "usage_key": usage_key,
            "username": self.student.username,
            "user": self.student,
        }
开发者ID:hjpijeira,项目名称:edx-platform,代码行数:29,代码来源:test_forms.py

示例2: _create_user

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
 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,代码行数:9,代码来源:test_base.py

示例3: test_data_err_fail

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:30,代码来源:test_err_handling.py

示例4: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:28,代码来源:test_spoc_gradebook.py

示例5: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:29,代码来源:test_split_test.py

示例6: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
 def setUp(self):
     super(CCXCoachTabTestCase, self).setUp()
     self.user = UserFactory.create()
     for course in [self.ccx_enabled_course, self.ccx_disabled_course]:
         CourseEnrollmentFactory.create(user=self.user, course_id=course.id)
         role = CourseCcxCoachRole(course.id)
         role.add_users(self.user)
开发者ID:Akif-Vohra,项目名称:edx-platform,代码行数:9,代码来源:test_views.py

示例7: _create_cert

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    def _create_cert(self, course_key, user, status):
        """Create a certificate entry. """
        # Enroll the user in the course
        CourseEnrollmentFactory.create(user=user, course_id=course_key)

        # Create the certificate
        GeneratedCertificate.objects.create(user=user, course_id=course_key, status=status)
开发者ID:ahmadiga,项目名称:min_edx,代码行数:9,代码来源:test_cert_management.py

示例8: create_course

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
 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,代码行数:27,代码来源:test_views.py

示例9: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:33,代码来源:test_dashboard_data.py

示例10: test_access_masquerade_as_user_with_forum_role

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:33,代码来源:test_access.py

示例11: test_double_denied

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
 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,代码行数:36,代码来源:test_access.py

示例12: test_access_masquerade_as_course_team_users

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:27,代码来源:test_access.py

示例13: test_access_course_team_users

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:28,代码来源:test_access.py

示例14: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    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,代码行数:31,代码来源:test_views.py

示例15: setUp

# 需要导入模块: from student.tests.factories import CourseEnrollmentFactory [as 别名]
# 或者: from student.tests.factories.CourseEnrollmentFactory import create [as 别名]
    def setUp(self):
        super(TestBlockListGetForm, self).setUp()

        self.student = UserFactory.create()
        self.student2 = UserFactory.create()
        self.staff = UserFactory.create(is_staff=True)

        CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
        CourseEnrollmentFactory.create(user=self.student2, course_id=self.course.id)

        usage_key = self.course.location
        self.initial = {'requesting_user': self.student}
        self.form_data = QueryDict(
            urlencode({
                'username': self.student.username,
                'usage_key': unicode(usage_key),
            }),
            mutable=True,
        )
        self.cleaned_data = {
            'all_blocks': None,
            'block_counts': set(),
            'depth': 0,
            'nav_depth': None,
            'return_type': 'dict',
            'requested_fields': {'display_name', 'type'},
            'student_view_data': set(),
            'usage_key': usage_key,
            'username': self.student.username,
            'user': self.student,
        }
开发者ID:28554010,项目名称:edx-platform,代码行数:33,代码来源:test_forms.py


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