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


Python factories.StaffFactory类代码示例

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


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

示例1: test__catalog_visibility

    def test__catalog_visibility(self):
        """
        Tests the catalog visibility tri-states
        """
        user = UserFactory.create()
        course_id = SlashSeparatedCourseKey("edX", "test", "2012_Fall")
        staff = StaffFactory.create(course_key=course_id)

        course = Mock(id=course_id, catalog_visibility=CATALOG_VISIBILITY_CATALOG_AND_ABOUT)
        self.assertTrue(access._has_access_course_desc(user, "see_in_catalog", course))
        self.assertTrue(access._has_access_course_desc(user, "see_about_page", course))
        self.assertTrue(access._has_access_course_desc(staff, "see_in_catalog", course))
        self.assertTrue(access._has_access_course_desc(staff, "see_about_page", course))

        # Now set visibility to just about page
        course = Mock(
            id=SlashSeparatedCourseKey("edX", "test", "2012_Fall"), catalog_visibility=CATALOG_VISIBILITY_ABOUT
        )
        self.assertFalse(access._has_access_course_desc(user, "see_in_catalog", course))
        self.assertTrue(access._has_access_course_desc(user, "see_about_page", course))
        self.assertTrue(access._has_access_course_desc(staff, "see_in_catalog", course))
        self.assertTrue(access._has_access_course_desc(staff, "see_about_page", course))

        # Now set visibility to none, which means neither in catalog nor about pages
        course = Mock(
            id=SlashSeparatedCourseKey("edX", "test", "2012_Fall"), catalog_visibility=CATALOG_VISIBILITY_NONE
        )
        self.assertFalse(access._has_access_course_desc(user, "see_in_catalog", course))
        self.assertFalse(access._has_access_course_desc(user, "see_about_page", course))
        self.assertTrue(access._has_access_course_desc(staff, "see_in_catalog", course))
        self.assertTrue(access._has_access_course_desc(staff, "see_about_page", course))
开发者ID:johnny-nan,项目名称:edx-platform,代码行数:31,代码来源:test_access.py

示例2: test_entrance_exam_gating_for_staff

    def test_entrance_exam_gating_for_staff(self):
        """
        Tests gating is disabled if user is member of staff.
        """

        # Login as member of staff
        self.client.logout()
        staff_user = StaffFactory(course_key=self.course.id)
        staff_user.is_staff = True
        self.client.login(username=staff_user.username, password='test')

        # assert staff has access to all toc
        self.request.user = staff_user
        unlocked_toc = self._return_table_of_contents()
        for toc_section in self.expected_unlocked_toc:
            self.assertIn(toc_section, unlocked_toc)
开发者ID:10clouds,项目名称:edx-platform,代码行数:16,代码来源:test_entrance_exam.py

示例3: setUp

    def setUp(self):
        super(TeamAPITestCase, self).setUp()
        self.topics_count = 4
        self.users = {
            "student_unenrolled": UserFactory.create(password=self.test_password),
            "student_enrolled": UserFactory.create(password=self.test_password),
            "student_enrolled_not_on_team": UserFactory.create(password=self.test_password),
            # This student is enrolled in both test courses and is a member of a team in each course, but is not on the
            # same team as student_enrolled.
            "student_enrolled_both_courses_other_team": UserFactory.create(password=self.test_password),
            "staff": AdminFactory.create(password=self.test_password),
            "course_staff": StaffFactory.create(course_key=self.test_course_1.id, password=self.test_password),
        }
        # 'solar team' is intentionally lower case to test case insensitivity in name ordering
        self.test_team_1 = CourseTeamFactory.create(
            name=u"sólar team", course_id=self.test_course_1.id, topic_id="topic_0"
        )
        self.test_team_2 = CourseTeamFactory.create(name="Wind Team", course_id=self.test_course_1.id)
        self.test_team_3 = CourseTeamFactory.create(name="Nuclear Team", course_id=self.test_course_1.id)
        self.test_team_4 = CourseTeamFactory.create(name="Coal Team", course_id=self.test_course_1.id, is_active=False)
        self.test_team_5 = CourseTeamFactory.create(name="Another Team", course_id=self.test_course_2.id)

        for user, course in [
            ("student_enrolled", self.test_course_1),
            ("student_enrolled_not_on_team", self.test_course_1),
            ("student_enrolled_both_courses_other_team", self.test_course_1),
            ("student_enrolled_both_courses_other_team", self.test_course_2),
        ]:
            CourseEnrollment.enroll(self.users[user], course.id, check_access=True)

        self.test_team_1.add_user(self.users["student_enrolled"])
        self.test_team_3.add_user(self.users["student_enrolled_both_courses_other_team"])
        self.test_team_5.add_user(self.users["student_enrolled_both_courses_other_team"])
开发者ID:rimolive,项目名称:edx-platform,代码行数:33,代码来源:test_views.py

示例4: test_access_on_course_with_pre_requisites

    def test_access_on_course_with_pre_requisites(self):
        """
        Test course access when a course has pre-requisite course yet to be completed
        """
        user = UserFactory.create()

        pre_requisite_course = CourseFactory.create(
            org='test_org', number='788', run='test_run'
        )

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org='test_org', number='786', run='test_run', pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        # user should not be able to load course even if enrolled
        CourseEnrollmentFactory(user=user, course_id=course.id)
        response = access._has_access_course(user, 'load', course)
        self.assertFalse(response)
        self.assertIsInstance(response, access_response.MilestoneAccessError)
        # Staff can always access course
        staff = StaffFactory.create(course_key=course.id)
        self.assertTrue(access._has_access_course(staff, 'load', course))

        # User should be able access after completing required course
        fulfill_course_milestone(pre_requisite_course.id, user)
        self.assertTrue(access._has_access_course(user, 'load', course))
开发者ID:luisvasq,项目名称:edx-platform,代码行数:28,代码来源:test_access.py

示例5: test_access_on_course_with_pre_requisites

    def test_access_on_course_with_pre_requisites(self):
        """
        Test course access when a course has pre-requisite course yet to be completed
        """
        seed_milestone_relationship_types()
        user = UserFactory.create()

        pre_requisite_course = CourseFactory.create(org="test_org", number="788", run="test_run")

        pre_requisite_courses = [unicode(pre_requisite_course.id)]
        course = CourseFactory.create(
            org="test_org", number="786", run="test_run", pre_requisite_courses=pre_requisite_courses
        )
        set_prerequisite_courses(course.id, pre_requisite_courses)

        # user should not be able to load course even if enrolled
        CourseEnrollmentFactory(user=user, course_id=course.id)
        response = access._has_access_course_desc(user, "view_courseware_with_prerequisites", course)
        self.assertFalse(response)
        self.assertIsInstance(response, access_response.MilestoneError)
        # Staff can always access course
        staff = StaffFactory.create(course_key=course.id)
        self.assertTrue(access._has_access_course_desc(staff, "view_courseware_with_prerequisites", course))

        # User should be able access after completing required course
        fulfill_course_milestone(pre_requisite_course.id, user)
        self.assertTrue(access._has_access_course_desc(user, "view_courseware_with_prerequisites", course))
开发者ID:johnny-nan,项目名称:edx-platform,代码行数:27,代码来源:test_access.py

示例6: setUp

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

        teams_configuration = {
            'topics':
            [
                {
                    'id': 'topic_{}'.format(i),
                    'name': name,
                    'description': 'Description for topic {}.'.format(i)
                } for i, name in enumerate([u'sólar power', 'Wind Power', 'Nuclear Power', 'Coal Power'])
            ]
        }
        self.topics_count = 4

        self.test_course_1 = CourseFactory.create(
            org='TestX',
            course='TS101',
            display_name='Test Course',
            teams_configuration=teams_configuration
        )
        self.test_course_2 = CourseFactory.create(org='MIT', course='6.002x', display_name='Circuits')

        self.users = {
            'student_unenrolled': UserFactory.create(password=self.test_password),
            'student_enrolled': UserFactory.create(password=self.test_password),
            'student_enrolled_not_on_team': UserFactory.create(password=self.test_password),

            # This student is enrolled in both test courses and is a member of a team in each course, but is not on the
            # same team as student_enrolled.
            'student_enrolled_both_courses_other_team': UserFactory.create(password=self.test_password),

            'staff': AdminFactory.create(password=self.test_password),
            'course_staff': StaffFactory.create(course_key=self.test_course_1.id, password=self.test_password)
        }
        # 'solar team' is intentionally lower case to test case insensitivity in name ordering
        self.test_team_1 = CourseTeamFactory.create(
            name=u'sólar team',
            course_id=self.test_course_1.id,
            topic_id='topic_0'
        )
        self.test_team_2 = CourseTeamFactory.create(name='Wind Team', course_id=self.test_course_1.id)
        self.test_team_3 = CourseTeamFactory.create(name='Nuclear Team', course_id=self.test_course_1.id)
        self.test_team_4 = CourseTeamFactory.create(name='Coal Team', course_id=self.test_course_1.id, is_active=False)
        self.test_team_5 = CourseTeamFactory.create(name='Another Team', course_id=self.test_course_2.id)

        for user, course in [
                ('student_enrolled', self.test_course_1),
                ('student_enrolled_not_on_team', self.test_course_1),
                ('student_enrolled_both_courses_other_team', self.test_course_1),
                ('student_enrolled_both_courses_other_team', self.test_course_2)
        ]:
            CourseEnrollment.enroll(
                self.users[user], course.id, check_access=True
            )

        self.test_team_1.add_user(self.users['student_enrolled'])
        self.test_team_3.add_user(self.users['student_enrolled_both_courses_other_team'])
        self.test_team_5.add_user(self.users['student_enrolled_both_courses_other_team'])
开发者ID:jaags,项目名称:edx-platform,代码行数:59,代码来源:test_views.py

示例7: test_courseware_page_access_with_staff_user_after_passing_entrance_exam

 def test_courseware_page_access_with_staff_user_after_passing_entrance_exam(self):
     """
     Test courseware access page after passing entrance exam but with staff user
     """
     self.logout()
     staff_user = StaffFactory.create(course_key=self.course.id)
     self.login(staff_user.email, 'test')
     CourseEnrollmentFactory(user=staff_user, course_id=self.course.id)
     self._assert_chapter_loaded(self.course, self.chapter)
开发者ID:10clouds,项目名称:edx-platform,代码行数:9,代码来源:test_entrance_exam.py

示例8: test__has_access_course_desc_can_enroll

    def test__has_access_course_desc_can_enroll(self):
        yesterday = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1)
        tomorrow = datetime.datetime.now(pytz.utc) + datetime.timedelta(days=1)

        # Non-staff can enroll if authenticated and specifically allowed for that course
        # even outside the open enrollment period
        user = UserFactory.create()
        course = Mock(
            enrollment_start=tomorrow,
            enrollment_end=tomorrow,
            id=SlashSeparatedCourseKey("edX", "test", "2012_Fall"),
            enrollment_domain="",
        )
        CourseEnrollmentAllowedFactory(email=user.email, course_id=course.id)
        self.assertTrue(access._has_access_course_desc(user, "enroll", course))

        # Staff can always enroll even outside the open enrollment period
        user = StaffFactory.create(course_key=course.id)
        self.assertTrue(access._has_access_course_desc(user, "enroll", course))

        # Non-staff cannot enroll if it is between the start and end dates and invitation only
        # and not specifically allowed
        course = Mock(
            enrollment_start=yesterday,
            enrollment_end=tomorrow,
            id=SlashSeparatedCourseKey("edX", "test", "2012_Fall"),
            enrollment_domain="",
            invitation_only=True,
        )
        user = UserFactory.create()
        self.assertFalse(access._has_access_course_desc(user, "enroll", course))

        # Non-staff can enroll if it is between the start and end dates and not invitation only
        course = Mock(
            enrollment_start=yesterday,
            enrollment_end=tomorrow,
            id=SlashSeparatedCourseKey("edX", "test", "2012_Fall"),
            enrollment_domain="",
            invitation_only=False,
        )
        self.assertTrue(access._has_access_course_desc(user, "enroll", course))

        # Non-staff cannot enroll outside the open enrollment period if not specifically allowed
        course = Mock(
            enrollment_start=tomorrow,
            enrollment_end=tomorrow,
            id=SlashSeparatedCourseKey("edX", "test", "2012_Fall"),
            enrollment_domain="",
            invitation_only=False,
        )
        self.assertFalse(access._has_access_course_desc(user, "enroll", course))
开发者ID:johnny-nan,项目名称:edx-platform,代码行数:51,代码来源:test_access.py

示例9: setUp

 def setUp(self):
     """
     Creates a test course ID, mocks the runtime, and creates a fake storage
     engine for use in all tests
     """
     super(StaffGradedAssignmentXblockTests, self).setUp()
     self.course = CourseFactory.create(org='foo', number='bar', display_name='baz')
     self.descriptor = ItemFactory(category="pure", parent=self.course)
     self.course_id = self.course.id
     self.instructor = StaffFactory.create(course_key=self.course_id)
     self.student_data = mock.Mock()
     self.staff = AdminFactory.create(password="test")
     self.runtime = self.make_runtime()
     self.scope_ids = self.make_scope_ids(self.runtime)
开发者ID:doctoryes,项目名称:edx-sga,代码行数:14,代码来源:integration_tests.py

示例10: setUp

    def setUp(self):
        super(TeamAPITestCase, self).setUp()
        self.topics_count = 4
        self.users = {
            'staff': AdminFactory.create(password=self.test_password),
            'course_staff': StaffFactory.create(course_key=self.test_course_1.id, password=self.test_password)
        }
        self.create_and_enroll_student(username='student_enrolled')
        self.create_and_enroll_student(username='student_enrolled_not_on_team')
        self.create_and_enroll_student(username='student_unenrolled', courses=[])

        # Make this student a community TA.
        self.create_and_enroll_student(username='community_ta')
        seed_permissions_roles(self.test_course_1.id)
        community_ta_role = Role.objects.get(name=FORUM_ROLE_COMMUNITY_TA, course_id=self.test_course_1.id)
        community_ta_role.users.add(self.users['community_ta'])

        # This student is enrolled in both test courses and is a member of a team in each course, but is not on the
        # same team as student_enrolled.
        self.create_and_enroll_student(
            courses=[self.test_course_1, self.test_course_2],
            username='student_enrolled_both_courses_other_team'
        )

        # 'solar team' is intentionally lower case to test case insensitivity in name ordering
        self.test_team_1 = CourseTeamFactory.create(
            name=u'sólar team',
            course_id=self.test_course_1.id,
            topic_id='topic_0'
        )
        self.test_team_2 = CourseTeamFactory.create(name='Wind Team', course_id=self.test_course_1.id)
        self.test_team_3 = CourseTeamFactory.create(name='Nuclear Team', course_id=self.test_course_1.id)
        self.test_team_4 = CourseTeamFactory.create(name='Coal Team', course_id=self.test_course_1.id, is_active=False)
        self.test_team_5 = CourseTeamFactory.create(name='Another Team', course_id=self.test_course_2.id)

        for user, course in [
                ('staff', self.test_course_1),
                ('course_staff', self.test_course_1),
        ]:
            CourseEnrollment.enroll(
                self.users[user], course.id, check_access=True
            )

        self.test_team_1.add_user(self.users['student_enrolled'])
        self.test_team_3.add_user(self.users['student_enrolled_both_courses_other_team'])
        self.test_team_5.add_user(self.users['student_enrolled_both_courses_other_team'])
开发者ID:nagyistoce,项目名称:edx-platform,代码行数:46,代码来源:test_views.py

示例11: test_runtime_user_is_staff

    def test_runtime_user_is_staff(self, is_staff):
        course = CourseFactory.create(org='org', number='bar', display_name='baz')
        descriptor = ItemFactory(category="pure", parent=course)

        staff = StaffFactory.create(course_key=course.id)
        self.runtime, _ = render.get_module_system_for_user(
            staff if is_staff else User.objects.create(),
            self.student_data,
            descriptor,
            course.id,
            mock.Mock(),
            mock.Mock(),
            mock.Mock(),
            course=course
        )
        block = self.make_one()
        assert block.runtime_user_is_staff() is is_staff
开发者ID:doctoryes,项目名称:edx-sga,代码行数:17,代码来源:integration_tests.py

示例12: test__catalog_visibility

    def test__catalog_visibility(self):
        """
        Tests the catalog visibility tri-states
        """
        user = UserFactory.create()
        course_id = CourseLocator('edX', 'test', '2012_Fall')
        staff = StaffFactory.create(course_key=course_id)

        course = Mock(
            id=course_id,
            catalog_visibility=CATALOG_VISIBILITY_CATALOG_AND_ABOUT
        )
        self.assertTrue(access._has_access_course(user, 'see_in_catalog', course))
        self.assertTrue(access._has_access_course(user, 'see_about_page', course))
        self.assertTrue(access._has_access_course(staff, 'see_in_catalog', course))
        self.assertTrue(access._has_access_course(staff, 'see_about_page', course))

        # Now set visibility to just about page
        course = Mock(
            id=CourseLocator('edX', 'test', '2012_Fall'),
            catalog_visibility=CATALOG_VISIBILITY_ABOUT
        )
        self.assertFalse(access._has_access_course(user, 'see_in_catalog', course))
        self.assertTrue(access._has_access_course(user, 'see_about_page', course))
        self.assertTrue(access._has_access_course(staff, 'see_in_catalog', course))
        self.assertTrue(access._has_access_course(staff, 'see_about_page', course))

        # Now set visibility to none, which means neither in catalog nor about pages
        course = Mock(
            id=CourseLocator('edX', 'test', '2012_Fall'),
            catalog_visibility=CATALOG_VISIBILITY_NONE
        )
        self.assertFalse(access._has_access_course(user, 'see_in_catalog', course))
        self.assertFalse(access._has_access_course(user, 'see_about_page', course))
        self.assertTrue(access._has_access_course(staff, 'see_in_catalog', course))
        self.assertTrue(access._has_access_course(staff, 'see_about_page', course))
开发者ID:luisvasq,项目名称:edx-platform,代码行数:36,代码来源:test_access.py

示例13: test_access_control

    def test_access_control(self):
        """
        Test that only topics that a user has access to are returned. The
        ways in which a user may not have access are:

        * Module is visible to staff only
        * Module has a start date in the future
        * Module is accessible only to a group the user is not in

        Also, there is a case that ensures that a category with no accessible
        subcategories does not appear in the result.
        """
        beta_tester = BetaTesterFactory.create(course_key=self.course.id)
        staff = StaffFactory.create(course_key=self.course.id)
        for user, group_idx in [(self.user, 0), (beta_tester, 1)]:
            cohort = CohortFactory.create(
                course_id=self.course.id,
                name=self.partition.groups[group_idx].name,
                users=[user]
            )
            CourseUserGroupPartitionGroup.objects.create(
                course_user_group=cohort,
                partition_id=self.partition.id,
                group_id=self.partition.groups[group_idx].id
            )

        self.make_discussion_module("courseware-1", "First", "Everybody")
        self.make_discussion_module(
            "courseware-2",
            "First",
            "Cohort A",
            group_access={self.partition.id: [self.partition.groups[0].id]}
        )
        self.make_discussion_module(
            "courseware-3",
            "First",
            "Cohort B",
            group_access={self.partition.id: [self.partition.groups[1].id]}
        )
        self.make_discussion_module("courseware-4", "Second", "Staff Only", visible_to_staff_only=True)
        self.make_discussion_module(
            "courseware-5",
            "Second",
            "Future Start Date",
            start=datetime.now(UTC) + timedelta(days=1)
        )

        student_actual = self.get_course_topics()
        student_expected = {
            "courseware_topics": [
                self.make_expected_tree(
                    None,
                    "First",
                    [
                        self.make_expected_tree("courseware-2", "Cohort A"),
                        self.make_expected_tree("courseware-1", "Everybody"),
                    ]
                ),
            ],
            "non_courseware_topics": [],
        }
        self.assertEqual(student_actual, student_expected)

        beta_actual = self.get_course_topics(beta_tester)
        beta_expected = {
            "courseware_topics": [
                self.make_expected_tree(
                    None,
                    "First",
                    [
                        self.make_expected_tree("courseware-3", "Cohort B"),
                        self.make_expected_tree("courseware-1", "Everybody"),
                    ]
                ),
                self.make_expected_tree(
                    None,
                    "Second",
                    [self.make_expected_tree("courseware-5", "Future Start Date")]
                ),
            ],
            "non_courseware_topics": [],
        }
        self.assertEqual(beta_actual, beta_expected)

        staff_actual = self.get_course_topics(staff)
        staff_expected = {
            "courseware_topics": [
                self.make_expected_tree(
                    None,
                    "First",
                    [
                        self.make_expected_tree("courseware-2", "Cohort A"),
                        self.make_expected_tree("courseware-3", "Cohort B"),
                        self.make_expected_tree("courseware-1", "Everybody"),
                    ]
                ),
                self.make_expected_tree(
                    None,
                    "Second",
                    [
#.........这里部分代码省略.........
开发者ID:unicri,项目名称:edx-platform,代码行数:101,代码来源:test_api.py

示例14: setUp

    def setUp(self):
        super(TeamAPITestCase, self).setUp()
        self.topics_count = 4
        self.users = {
            'staff': AdminFactory.create(password=self.test_password),
            'course_staff': StaffFactory.create(course_key=self.test_course_1.id, password=self.test_password)
        }
        self.create_and_enroll_student(username='student_enrolled')
        self.create_and_enroll_student(username='student_enrolled_not_on_team')
        self.create_and_enroll_student(username='student_unenrolled', courses=[])

        # Make this student a community TA.
        self.create_and_enroll_student(username='community_ta')
        seed_permissions_roles(self.test_course_1.id)
        community_ta_role = Role.objects.get(name=FORUM_ROLE_COMMUNITY_TA, course_id=self.test_course_1.id)
        community_ta_role.users.add(self.users['community_ta'])

        # This student is enrolled in both test courses and is a member of a team in each course, but is not on the
        # same team as student_enrolled.
        self.create_and_enroll_student(
            courses=[self.test_course_1, self.test_course_2],
            username='student_enrolled_both_courses_other_team'
        )

        # Make this student have a public profile
        self.create_and_enroll_student(
            courses=[self.test_course_2],
            username='student_enrolled_public_profile'
        )
        profile = self.users['student_enrolled_public_profile'].profile
        profile.year_of_birth = 1970
        profile.save()

        # This student is enrolled in the other course, but not yet a member of a team. This is to allow
        # course_2 to use a max_team_size of 1 without breaking other tests on course_1
        self.create_and_enroll_student(
            courses=[self.test_course_2],
            username='student_enrolled_other_course_not_on_team'
        )

        # 'solar team' is intentionally lower case to test case insensitivity in name ordering
        self.test_team_1 = CourseTeamFactory.create(
            name=u'sólar team',
            course_id=self.test_course_1.id,
            topic_id='topic_0'
        )
        self.test_team_2 = CourseTeamFactory.create(name='Wind Team', course_id=self.test_course_1.id)
        self.test_team_3 = CourseTeamFactory.create(name='Nuclear Team', course_id=self.test_course_1.id)
        self.test_team_4 = CourseTeamFactory.create(name='Coal Team', course_id=self.test_course_1.id, is_active=False)
        self.test_team_5 = CourseTeamFactory.create(name='Another Team', course_id=self.test_course_2.id)
        self.test_team_6 = CourseTeamFactory.create(
            name='Public Profile Team',
            course_id=self.test_course_2.id,
            topic_id='topic_6'
        )

        self.test_team_name_id_map = {team.name: team for team in (
            self.test_team_1,
            self.test_team_2,
            self.test_team_3,
            self.test_team_4,
            self.test_team_5,
        )}

        for user, course in [('staff', self.test_course_1), ('course_staff', self.test_course_1)]:
            CourseEnrollment.enroll(
                self.users[user], course.id, check_access=True
            )

        self.test_team_1.add_user(self.users['student_enrolled'])
        self.test_team_3.add_user(self.users['student_enrolled_both_courses_other_team'])
        self.test_team_5.add_user(self.users['student_enrolled_both_courses_other_team'])
        self.test_team_6.add_user(self.users['student_enrolled_public_profile'])
开发者ID:vehery,项目名称:edx-platform,代码行数:73,代码来源:test_views.py

示例15: setUp

    def setUp(self):
        super(TeamAPITestCase, self).setUp()
        self.topics_count = 4
        self.users = {
            'staff': AdminFactory.create(password=self.test_password),
            'course_staff': StaffFactory.create(course_key=self.test_course_1.id, password=self.test_password)
        }
        self.create_and_enroll_student(username='student_enrolled')
        self.create_and_enroll_student(username='student_enrolled_not_on_team')
        self.create_and_enroll_student(username='student_unenrolled', courses=[])

        # Make this student a community TA.
        self.create_and_enroll_student(username='community_ta')
        seed_permissions_roles(self.test_course_1.id)
        community_ta_role = Role.objects.get(name=FORUM_ROLE_COMMUNITY_TA, course_id=self.test_course_1.id)
        community_ta_role.users.add(self.users['community_ta'])

        # This student is enrolled in both test courses and is a member of a team in each course, but is not on the
        # same team as student_enrolled.
        self.create_and_enroll_student(
            courses=[self.test_course_1, self.test_course_2],
            username='student_enrolled_both_courses_other_team'
        )

        # Make this student have a public profile
        self.create_and_enroll_student(
            courses=[self.test_course_2],
            username='student_enrolled_public_profile'
        )
        profile = self.users['student_enrolled_public_profile'].profile
        profile.year_of_birth = 1970
        profile.save()

        # This student is enrolled in the other course, but not yet a member of a team. This is to allow
        # course_2 to use a max_team_size of 1 without breaking other tests on course_1
        self.create_and_enroll_student(
            courses=[self.test_course_2],
            username='student_enrolled_other_course_not_on_team'
        )

        with skip_signal(
            post_save,
            receiver=course_team_post_save_callback,
            sender=CourseTeam,
            dispatch_uid='teams.signals.course_team_post_save_callback'
        ):
            self.solar_team = CourseTeamFactory.create(
                name=u'Sólar team',
                course_id=self.test_course_1.id,
                topic_id='topic_0'
            )
            self.wind_team = CourseTeamFactory.create(name='Wind Team', course_id=self.test_course_1.id)
            self.nuclear_team = CourseTeamFactory.create(name='Nuclear Team', course_id=self.test_course_1.id)
            self.another_team = CourseTeamFactory.create(name='Another Team', course_id=self.test_course_2.id)
            self.public_profile_team = CourseTeamFactory.create(
                name='Public Profile Team',
                course_id=self.test_course_2.id,
                topic_id='topic_6'
            )
            self.search_team = CourseTeamFactory.create(
                name='Search',
                description='queryable text',
                country='GS',
                language='to',
                course_id=self.test_course_2.id,
                topic_id='topic_7'
            )

        self.test_team_name_id_map = {team.name: team for team in (
            self.solar_team,
            self.wind_team,
            self.nuclear_team,
            self.another_team,
            self.public_profile_team,
            self.search_team,
        )}

        for user, course in [('staff', self.test_course_1), ('course_staff', self.test_course_1)]:
            CourseEnrollment.enroll(
                self.users[user], course.id, check_access=True
            )

        self.solar_team.add_user(self.users['student_enrolled'])
        self.nuclear_team.add_user(self.users['student_enrolled_both_courses_other_team'])
        self.another_team.add_user(self.users['student_enrolled_both_courses_other_team'])
        self.public_profile_team.add_user(self.users['student_enrolled_public_profile'])
开发者ID:chauhanhardik,项目名称:populo,代码行数:86,代码来源:test_views.py


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