def setUp(self): super(CertificateisInvalid, self).setUp() self.student = UserFactory() self.course = CourseFactory.create( org='edx', number='verified', display_name='Verified Course' ) self.global_staff = GlobalStaffFactory() self.request_factory = RequestFactory()
def setUp(self): super(AccessTestCase, self).setUp() self.course = CourseFactory.create(org='edX', course='toy', run='test_run') self.anonymous_user = AnonymousUserFactory() self.beta_user = BetaTesterFactory(course_key=self.course.id) self.student = UserFactory() self.global_staff = UserFactory(is_staff=True) self.course_staff = StaffFactory(course_key=self.course.id) self.course_instructor = InstructorFactory(course_key=self.course.id) self.staff = GlobalStaffFactory()
def setUpClass(cls): super(CurrentGradeViewTest, cls).setUpClass() cls.course = CourseFactory.create(display_name='test course', run="Testing_course") with cls.store.bulk_operations(cls.course.id): chapter = ItemFactory.create( category='chapter', parent_location=cls.course.location, display_name="Chapter 1", ) # create a problem for each type and minimum count needed by the grading policy # A section is not considered if the student answers less than "min_count" problems for grading_type, min_count in (("Homework", 12), ("Lab", 12), ("Midterm Exam", 1), ("Final Exam", 1)): for num in xrange(min_count): section = ItemFactory.create( category='sequential', parent_location=chapter.location, due=datetime(2013, 9, 18, 11, 30, 00, tzinfo=UTC), display_name='Sequential {} {}'.format(grading_type, num), format=grading_type, graded=True, ) vertical = ItemFactory.create( category='vertical', parent_location=section.location, display_name='Vertical {} {}'.format(grading_type, num), ) ItemFactory.create( category='problem', parent_location=vertical.location, display_name='Problem {} {}'.format(grading_type, num), ) cls.course_key = cls.course.id cls.password = '******' cls.student = UserFactory(username='******', password=cls.password) cls.other_student = UserFactory(username='******', password=cls.password) cls.other_user = UserFactory(username='******', password=cls.password) cls.staff = StaffFactory(course_key=cls.course.id, password=cls.password) cls.global_staff = GlobalStaffFactory.create() date = datetime(2013, 1, 22, tzinfo=UTC) for user in (cls.student, cls.other_student, ): CourseEnrollmentFactory( course_id=cls.course.id, user=user, created=date, ) cls.namespaced_url = 'grades_api:user_grade_detail'
def setUp(self): super().setUp() self.global_staff = GlobalStaffFactory() self.user = UserFactory() self.course_run = CourseFactory() self.course_run_key = self.course_run.id # pylint: disable=no-member CourseEnrollmentFactory( user=self.user, course_id=self.course_run_key, is_active=True, mode="verified", )
def setUpClass(cls): super(ListViewTestMixin, cls).setUpClass() cls.program_uuid = '00000000-1111-2222-3333-444444444444' cls.curriculum_uuid = 'aaaaaaaa-1111-2222-3333-444444444444' cls.other_curriculum_uuid = 'bbbbbbbb-1111-2222-3333-444444444444' cls.course_id = CourseKey.from_string('course-v1:edX+ToyX+Toy_Course') _ = CourseOverviewFactory.create(id=cls.course_id) cls.password = '******' cls.student = UserFactory.create(username='******', password=cls.password) cls.global_staff = GlobalStaffFactory.create(username='******', password=cls.password)
def setUp(self): super(TestViewAuth, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(number='999', display_name='Robot_Super_Course') self.courseware_chapter = ItemFactory.create(display_name='courseware') self.overview_chapter = ItemFactory.create( parent_location=self.course.location, display_name='Super Overview') self.welcome_section = ItemFactory.create( parent_location=self.overview_chapter.location, display_name='Super Welcome') self.welcome_unit = ItemFactory.create( parent_location=self.welcome_section.location, display_name='Super Unit') self.course = modulestore().get_course(self.course.id) self.test_course = CourseFactory.create(org=self.course.id.org) self.other_org_course = CourseFactory.create(org='Other_Org_Course') self.sub_courseware_chapter = ItemFactory.create( parent_location=self.test_course.location, display_name='courseware') self.sub_overview_chapter = ItemFactory.create( parent_location=self.sub_courseware_chapter.location, display_name='Overview') self.sub_welcome_section = ItemFactory.create( parent_location=self.sub_overview_chapter.location, display_name='Welcome') self.sub_welcome_unit = ItemFactory.create( parent_location=self.sub_welcome_section.location, display_name='New Unit') self.test_course = modulestore().get_course(self.test_course.id) self.global_staff_user = GlobalStaffFactory() self.unenrolled_user = UserFactory(last_name="Unenrolled") self.enrolled_user = UserFactory(last_name="Enrolled") CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.course.id) CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.test_course.id) self.staff_user = StaffFactory(course_key=self.course.id) self.instructor_user = InstructorFactory(course_key=self.course.id) self.org_staff_user = OrgStaffFactory(course_key=self.course.id) self.org_instructor_user = OrgInstructorFactory( course_key=self.course.id)
def setUpClass(cls): super(GradeViewTestMixin, cls).setUpClass() cls.course = cls._create_test_course_with_default_grading_policy( display_name='test course', run="Testing_course" ) cls.empty_course = cls._create_test_course_with_default_grading_policy( display_name='empty test course', run="Empty_testing_course" ) cls.course_key = cls.course.id cls.password = '******' cls.student = UserFactory(username='******', password=cls.password) cls.other_student = UserFactory(username='******', password=cls.password) cls.other_user = UserFactory(username='******', password=cls.password) cls.staff = StaffFactory(course_key=cls.course_key, password=cls.password) cls.global_staff = GlobalStaffFactory.create() cls._create_user_enrollments(cls.course, cls.student, cls.other_student)
def setUp(self): super(ProgramEnrollmentViewPatchTests, self).setUp() self.program_uuid = '00000000-1111-2222-3333-444444444444' self.curriculum_uuid = 'aaaaaaaa-1111-2222-3333-444444444444' self.other_curriculum_uuid = 'bbbbbbbb-1111-2222-3333-444444444444' self.course_id = CourseKey.from_string('course-v1:edX+ToyX+Toy_Course') _ = CourseOverviewFactory.create(id=self.course_id) self.password = '******' self.student = UserFactory.create(username='******', password=self.password) self.global_staff = GlobalStaffFactory.create(username='******', password=self.password) self.client.login(username=self.global_staff.username, password=self.password)
def setUp(self): super().setUp() self.course_key = CourseKey.from_string('course-v1:edX+ToyX+Toy_Course') self.other_course_key = CourseKey.from_string('course-v1:edX+ToyX_Other_Course+Toy_Course') self.course = self.create_course_from_course_key(self.course_key) self.other_course = self.create_course_from_course_key(self.other_course_key) self.password = '******' self.student = UserFactory.create(username='******', password=self.password) self.global_staff = GlobalStaffFactory(username='******', password=self.password) self.course_instructor = InstructorFactory( username='******', password=self.password, course_key=self.course.id, ) self.other_course_instructor = InstructorFactory( username='******', password=self.password, course_key=self.other_course.id, )
def test_preview_theme_access(self): """ Verify that users have the correct access to preview themes. """ # Anonymous users get redirected to the login page response = self.client.get(THEMING_ADMIN_URL) self.assertRedirects( response, '{login_url}?next={url}'.format( login_url=settings.LOGIN_URL, url=THEMING_ADMIN_URL, )) # Logged in non-global staff get a 404 self.client.login(username=self.user.username, password=TEST_PASSWORD) response = self.client.get(THEMING_ADMIN_URL) self.assertEqual(response.status_code, 404) # Global staff can access the page global_staff = GlobalStaffFactory() self.client.login(username=global_staff.username, password=TEST_PASSWORD) response = self.client.get(THEMING_ADMIN_URL) self.assertEqual(response.status_code, 200)
def setUp(self): super(GradeViewTestMixin, self).setUp() self.password = '******' self.global_staff = GlobalStaffFactory.create() self.student = UserFactory(password=self.password, username='******', email='*****@*****.**') self.other_student = UserFactory( password=self.password, username='******', email='*****@*****.**', ) self.program_student = UserFactory( password=self.password, username='******', email='*****@*****.**', ) self.program_masters_student = UserFactory( password=self.password, username='******', email='*****@*****.**', ) self._create_user_enrollments(self.student, self.other_student) self._create_user_program_enrollments(self.program_student) self._create_user_program_enrollments(self.program_masters_student, mode='masters')
def setUpClass(cls): super().setUpClass() cls.course_key = CourseKey.from_string('course-v1:edX+ToyX+Toy_Course') cls.other_course_key = CourseKey.from_string( 'course-v1:edX+ToyX_Other_Course+Toy_Course') cls.course = cls.create_course_from_course_key(cls.course_key) cls.other_course = cls.create_course_from_course_key( cls.other_course_key) cls.password = '******' cls.student = UserFactory.create(username='******', password=cls.password) cls.global_staff = GlobalStaffFactory(username='******', password=cls.password) cls.course_instructor = InstructorFactory( username='******', password=cls.password, course_key=cls.course.id, ) cls.other_course_instructor = InstructorFactory( username='******', password=cls.password, course_key=cls.other_course.id, )
def test_access_denied_fragment_for_full_access_users(self): """ Test that Full Access users do not see the access_denied_fragment or access_denied_message """ mock_request = RequestFactory().get('/') mock_course = Mock(id=self.course_key, user_partitions={}) mock_block = Mock(scope_ids=Mock(usage_id=Mock(course_key=mock_course.id))) CourseModeFactory.create(course_id=mock_course.id, mode_slug='verified') global_staff = GlobalStaffFactory.create() ContentTypeGatingConfig.objects.create(enabled=False, studio_override_enabled=True) partition = create_content_gating_partition(mock_course) with patch( 'crum.get_current_request', return_value=mock_request ): fragment = partition.access_denied_fragment(mock_block, global_staff, FULL_ACCESS, 'test_allowed_group') self.assertIsNone(fragment) message = partition.access_denied_message(mock_block.scope_ids.usage_id, global_staff, FULL_ACCESS, 'test_allowed_group') self.assertIsNone(message)
def setUpTestData(cls): cls.chapter0 = ItemFactory.create(parent=cls.course, display_name='Overview') cls.chapter9 = ItemFactory.create(parent=cls.course, display_name='factory_chapter') cls.section0 = ItemFactory.create(parent=cls.chapter0, display_name='Welcome') cls.section9 = ItemFactory.create(parent=cls.chapter9, display_name='factory_section') cls.unit0 = ItemFactory.create(parent=cls.section0, display_name='New Unit 0') cls.chapterchrome = ItemFactory.create(parent=cls.course, display_name='Chrome') cls.chromelesssection = ItemFactory.create(parent=cls.chapterchrome, display_name='chromeless', chrome='none') cls.accordionsection = ItemFactory.create(parent=cls.chapterchrome, display_name='accordion', chrome='accordion') cls.tabssection = ItemFactory.create(parent=cls.chapterchrome, display_name='tabs', chrome='tabs') cls.defaultchromesection = ItemFactory.create( parent=cls.chapterchrome, display_name='defaultchrome', ) cls.fullchromesection = ItemFactory.create(parent=cls.chapterchrome, display_name='fullchrome', chrome='accordion,tabs') cls.tabtest = ItemFactory.create(parent=cls.chapterchrome, display_name='pdf_textbooks_tab', default_tab='progress') cls.staff_user = GlobalStaffFactory() cls.user = UserFactory()
def test_acess_denied_fragment_for_null_request(self): """ Verifies the access denied fragment is visible when HTTP request is not available. Given the HTTP request instance is None Then set the mobile_app context variable to False And the fragment should be created successfully """ mock_request = None mock_course = Mock(id=self.course_key, user_partitions={}) mock_block = Mock(scope_ids=Mock(usage_id=Mock(course_key=mock_course.id))) CourseModeFactory.create(course_id=mock_course.id, mode_slug='audit') CourseModeFactory.create(course_id=mock_course.id, mode_slug='verified') global_staff = GlobalStaffFactory.create() ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1)) partition = create_content_gating_partition(mock_course) with patch( 'crum.get_current_request', return_value=mock_request ): fragment = partition.access_denied_fragment(mock_block, global_staff, LIMITED_ACCESS, [FULL_ACCESS]) self.assertIsNotNone(fragment)
def create_user_and_access_token(self): self.user = GlobalStaffFactory.create() self.oauth_client = ApplicationFactory.create() self.access_token = AccessTokenFactory.create( user=self.user, application=self.oauth_client).token
def create_user_and_access_token(self): # pylint: disable=missing-docstring self.user = GlobalStaffFactory.create() self.oauth_client = ClientFactory.create() self.access_token = AccessTokenFactory.create( user=self.user, client=self.oauth_client).token
def setUp(self): super(ProgramEnrollmentViewPostTests, self).setUp() global_staff = GlobalStaffFactory.create(username='******', password='******') self.client.login(username=global_staff.username, password='******')