def setUp(self): super().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 setUp(self): super().setUp() for idx, student in enumerate(self.STUDENTS): username = f"u{idx}" self.create_account(username, student['email'], student['password']) self.activate_user(student['email']) self.logout() self.staff_user = GlobalStaffFactory()
def setUp(self): super().setUp() self.student = UserFactory() self.course = CourseFactory.create(org='edx', number='verified', display_name='Verified Course') self.course_overview = CourseOverviewFactory.create(id=self.course.id) self.global_staff = GlobalStaffFactory() self.request_factory = RequestFactory()
def setUp(self): super().setUp() self.course1 = CourseFactory() self.course2 = CourseFactory() self.global_staff = GlobalStaffFactory(username="******") self.instructor_course1 = InstructorFactory.create( course_key=self.course1.id, username="******") self.instructor_course2 = InstructorFactory.create( course_key=self.course2.id, username="******") self.staff = StaffFactory.create(course_key=self.course1.id, username="******") self.user = UserFactory(username="******")
def setUp(self): super().setUp() self.course_key = CourseKey.from_string( 'course-v1:Test+Course+Configured') self.url = reverse('discussions', kwargs={ 'course_key_string': str(self.course_key), }) self.password = '******' self.user_student = UserFactory(username='******', password=self.password) self.user_staff_course = StaffFactory(course_key=self.course_key, password=self.password) self.user_staff_global = GlobalStaffFactory(password=self.password)
def setUp(self): super().setUp() self.user = UserFactory() self.global_staff = GlobalStaffFactory() 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 setUp(self) -> None: super().setUp() self.test_course_id = 'course-v1:edX+Test+1' self.user = UserFactory() self.global_staff = GlobalStaffFactory.create() _ = FinancialAssistanceConfigurationFactory( api_base_url='http://financial.assistance.test:1234', service_username=self.global_staff.username, fa_backend_enabled_courses_percentage=100, enabled=True) _ = Application.objects.create( name='Test Application', user=self.global_staff, client_type=Application.CLIENT_PUBLIC, authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS, )
def setUp(self): super().setUp() 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 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_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') assert fragment is None message = partition.access_denied_message(mock_block.scope_ids.usage_id, global_staff, FULL_ACCESS, 'test_allowed_group') assert message is None
def setUp(self): super().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 setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called 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_access_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]) assert fragment is not None
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