def test_access_denied_fragment_for_masquerading(self): """ Test that a global staff sees gated content flag when viewing course as `Learner in Audit` Note: Global staff doesn't require to be enrolled in course. """ 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))) mock_course_masquerade = Mock( role='student', user_partition_id=ENROLLMENT_TRACK_PARTITION_ID, group_id=settings.COURSE_ENROLLMENT_MODES['audit']['id'], user_name=None) 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( 'courseware.masquerade.get_course_masquerade', return_value=mock_course_masquerade ), patch( 'openedx.features.content_type_gating.partitions.get_course_masquerade', return_value=mock_course_masquerade), patch( 'crum.get_current_request', return_value=mock_request): fragment = partition.access_denied_fragment( mock_block, global_staff, GroupFactory(), 'test_allowed_group') self.assertIsNotNone(fragment)
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() 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, )
def test_access_denied_fragment_for_masquerading(self): """ Test that a global staff sees gated content flag when viewing course as `Learner in Audit` Note: Global staff doesn't require to be enrolled in course. """ 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))) mock_course_masquerade = Mock( role='student', user_partition_id=ENROLLMENT_TRACK_PARTITION_ID, group_id=settings.COURSE_ENROLLMENT_MODES['audit']['id'], user_name=None ) 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( 'courseware.masquerade.get_course_masquerade', return_value=mock_course_masquerade ), patch( 'openedx.features.content_type_gating.partitions.get_course_masquerade', return_value=mock_course_masquerade ), patch( 'crum.get_current_request', return_value=mock_request ): fragment = partition.access_denied_fragment(mock_block, global_staff, GroupFactory(), 'test_allowed_group') self.assertIsNotNone(fragment)
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() 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, )
def test_access_denied_fragment_for_masquerading(self): """ Test that a global staff sees gated content flag when viewing course as `Learner in Limited Access` Note: Global staff doesn't require to be enrolled in course. """ 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))) mock_course_masquerade = Mock( role='student', user_partition_id=CONTENT_GATING_PARTITION_ID, group_id=LIMITED_ACCESS.id, user_name=None ) 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, LIMITED_ACCESS, [FULL_ACCESS]) self.assertIsNotNone(fragment)
def setUp(self): super(GradeViewTestMixin, self).setUp() self.password = '******' self.global_staff = GlobalStaffFactory.create() self.student = UserFactory(password=self.password, username='******') self.other_student = UserFactory(password=self.password, username='******') self._create_user_enrollments(self.student, self.other_student)
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='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 ), patch( 'openedx.features.content_type_gating.partitions.ContentTypeGatingPartition._is_audit_enrollment', return_value=True ): fragment = partition.access_denied_fragment(mock_block, global_staff, GroupFactory(), 'test_allowed_group') self.assertIsNotNone(fragment)
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 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(GradeViewTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments 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 setUp(self): super(GradeViewTestMixin, self).setUp() self.password = '******' self.global_staff = GlobalStaffFactory.create() self.student = UserFactory(password=self.password) self.other_student = UserFactory(password=self.password) self._create_user_enrollments(self.student, self.other_student)
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='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 ), patch( 'openedx.features.content_type_gating.partitions.ContentTypeGatingPartition._is_audit_enrollment', return_value=True): fragment = partition.access_denied_fragment( mock_block, global_staff, GroupFactory(), 'test_allowed_group') self.assertIsNotNone(fragment)
def setUpClass(cls): super(BaseCourseEnrollmentTestsMixin, cls).setUpClass() cls.start_cache_isolation() cls.password = '******' cls.student = UserFactory.create(username='******', password=cls.password) cls.global_staff = GlobalStaffFactory.create(username='******', password=cls.password)
def setUpClass(cls): super(ProgramEnrollmentListTest, cls).setUpClass() cls.program_uuid = '00000000-1111-2222-3333-444444444444' cls.curriculum_uuid = 'aaaaaaaa-1111-2222-3333-444444444444' cls.password = '******' cls.student = UserFactory.create(username='******', password=cls.password) cls.global_staff = GlobalStaffFactory.create(username='******', password=cls.password)
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 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 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 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, global_staff, FULL_ACCESS, 'test_allowed_group') self.assertIsNone(message)
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 setUp(self): super(ProgramEnrollmentViewPostTests, self).setUp() global_staff = GlobalStaffFactory.create(username='******', password='******') self.client.login(username=global_staff.username, password='******')
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 create_user_and_access_token(self): self.user = GlobalStaffFactory.create() self.oauth_client = ClientFactory.create() self.access_token = AccessTokenFactory.create(user=self.user, client=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