Exemplo n.º 1
0
    def setUp(self):

        self.test_course = CourseFactory.create(
            display_name='Robot_Sub_Course')
        self.course = CourseFactory.create(display_name='Robot_Super_Course')
        self.chapter0 = ItemFactory.create(
            parent_location=self.course.location, display_name='Overview')
        self.chapter9 = ItemFactory.create(
            parent_location=self.course.location,
            display_name='factory_chapter')
        self.section0 = ItemFactory.create(
            parent_location=self.chapter0.location, display_name='Welcome')
        self.section9 = ItemFactory.create(
            parent_location=self.chapter9.location,
            display_name='factory_section')
        self.unit0 = ItemFactory.create(parent_location=self.section0.location,
                                        display_name='New Unit')

        # Create student accounts and activate them.
        for i in range(len(self.STUDENT_INFO)):
            email, password = self.STUDENT_INFO[i]
            username = '******'.format(i)
            self.create_account(username, email, password)
            self.activate_user(email)

        self.staff_user = GlobalStaffFactory()
Exemplo n.º 2
0
    def setUp(self):

        self.course = CourseFactory.create(number='999',
                                           display_name='Robot_Super_Course')
        self.overview_chapter = ItemFactory.create(display_name='Overview')
        self.courseware_chapter = ItemFactory.create(display_name='courseware')

        self.test_course = CourseFactory.create(
            number='666', display_name='Robot_Sub_Course')
        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.welcome_section = ItemFactory.create(
            parent_location=self.overview_chapter.location,
            display_name='Welcome')

        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=self.course.location)
        self.instructor_user = InstructorFactory(course=self.course.location)
        self.org_staff_user = OrgStaffFactory(course=self.course.location)
        self.org_instructor_user = OrgInstructorFactory(
            course=self.course.location)
Exemplo n.º 3
0
 def setUp(self):
     """ Set up the user and request that will be used. """
     self.staff_user = GlobalStaffFactory.create()
     self.request = RequestFactory().get('/')
     self.request.user = self.staff_user
     self.request.session = {}
     self.module = None
Exemplo n.º 4
0
    def setUp(self):
        super(CertificateExceptionViewInstructorApiTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.user = UserFactory()
        self.user2 = UserFactory()
        CourseEnrollment.enroll(self.user, self.course.id)
        CourseEnrollment.enroll(self.user2, self.course.id)
        self.url = reverse('certificate_exception_view', kwargs={'course_id': unicode(self.course.id)})

        certificate_white_list_item = CertificateWhitelistFactory.create(
            user=self.user2,
            course_id=self.course.id,
        )

        self.certificate_exception = dict(
            created="",
            notes="Test Notes for Test Certificate Exception",
            user_email='',
            user_id='',
            user_name=unicode(self.user.username)
        )

        self.certificate_exception_in_db = dict(
            id=certificate_white_list_item.id,
            user_name=certificate_white_list_item.user.username,
            notes=certificate_white_list_item.notes,
            user_email=certificate_white_list_item.user.email,
            user_id=certificate_white_list_item.user.id,
        )

        # Enable certificate generation
        cache.clear()
        CertificateGenerationConfiguration.objects.create(enabled=True)
        self.client.login(username=self.global_staff.username, password='******')
Exemplo n.º 5
0
    def test_preview_theme(self):
        """
        Verify that preview themes behaves correctly.
        """
        global_staff = GlobalStaffFactory()
        self.client.login(username=global_staff.username,
                          password=TEST_PASSWORD)

        # First request a preview theme
        post_response = self.client.post(THEMING_ADMIN_URL, {
            'action': 'set_preview_theme',
            'preview_theme': TEST_THEME_NAME,
        })
        self.assertRedirects(post_response, THEMING_ADMIN_URL)

        # Next request a page and verify that the correct theme has been chosen
        response = self.client.get(THEMING_ADMIN_URL)
        self.assertEquals(response.status_code, 200)
        self.assertContains(
            response, '<option value="{theme_name}" selected=selected>'.format(
                theme_name=TEST_THEME_NAME))

        # Request to reset the theme
        post_response = self.client.post(THEMING_ADMIN_URL,
                                         {'action': 'reset_preview_theme'})
        self.assertRedirects(post_response, THEMING_ADMIN_URL)

        # Finally verify that the test theme is no longer selected
        response = self.client.get(THEMING_ADMIN_URL)
        self.assertEquals(response.status_code, 200)
        self.assertContains(
            response,
            '<option value="{theme_name}">'.format(theme_name=TEST_THEME_NAME))
Exemplo n.º 6
0
    def setUp(self):
        super(TestCertificatesInstructorApiBulkWhiteListExceptions, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.enrolled_user_1 = UserFactory(
            username='******',
            email='*****@*****.**',
            first_name='Enrolled',
            last_name='Student'
        )
        self.enrolled_user_2 = UserFactory(
            username='******',
            email='*****@*****.**',
            first_name='Enrolled',
            last_name='Student'
        )

        self.not_enrolled_student = UserFactory(
            username='******',
            email='*****@*****.**',
            first_name='NotEnrolled',
            last_name='Student'
        )
        CourseEnrollment.enroll(self.enrolled_user_1, self.course.id)
        CourseEnrollment.enroll(self.enrolled_user_2, self.course.id)

        # Global staff can see the certificates section
        self.client.login(username=self.global_staff.username, password="******")
 def setUp(self):
     """ Set up the user and request that will be used. """
     self.staff_user = GlobalStaffFactory.create()
     self.request = RequestFactory().get('/')
     self.request.user = self.staff_user
     self.request.session = {}
     self.module = None
Exemplo n.º 8
0
    def setUp(self):
        super(CertificatesInstructorApiTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)

        # Enable certificate generation
        cache.clear()
        CertificateGenerationConfiguration.objects.create(enabled=True)
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    def setUp(self):
        super(TestRecommender, self).setUp()
        for idx, student in enumerate(self.STUDENTS):
            username = "******".format(idx)
            self.create_account(username, student['email'],
                                student['password'])
            self.activate_user(student['email'])

        self.staff_user = GlobalStaffFactory()
Exemplo n.º 11
0
 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()
Exemplo n.º 12
0
    def setUp(self):
        super(CertificatesInstructorDashTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)

        # Need to clear the cache for model-based configuration
        cache.clear()

        # Enable the certificate generation feature
        CertificateGenerationConfiguration.objects.create(enabled=True)
Exemplo n.º 13
0
 def setUp(self):
     super(AccessTestCase, self).setUp()
     course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
     self.course = course_key.make_usage_key('course', course_key.run)
     self.anonymous_user = AnonymousUserFactory()
     self.beta_user = BetaTesterFactory(course_key=self.course.course_key)
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course.course_key)
     self.course_instructor = InstructorFactory(
         course_key=self.course.course_key)
     self.staff = GlobalStaffFactory()
Exemplo n.º 14
0
    def setUp(self):
        super(CertificatesInstructorDashTest, self).setUp()
        self.course = CourseFactory.create()
        self.url = reverse('instructor_dashboard',
                           kwargs={'course_id': unicode(self.course.id)})
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)

        # Need to clear the cache for model-based configuration
        cache.clear()

        # Enable the certificate generation feature
        CertificateGenerationConfiguration.objects.create(enabled=True)
Exemplo n.º 15
0
    def setUp(self):
        super(TestViewAuth, self).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)
Exemplo n.º 16
0
    def setUp(self):
        super(TestNavigation, self).setUp()

        self.test_course = CourseFactory.create()
        self.course = CourseFactory.create()
        self.chapter0 = ItemFactory.create(parent=self.course,
                                           display_name='Overview')
        self.chapter9 = ItemFactory.create(parent=self.course,
                                           display_name='factory_chapter')
        self.section0 = ItemFactory.create(parent=self.chapter0,
                                           display_name='Welcome')
        self.section9 = ItemFactory.create(parent=self.chapter9,
                                           display_name='factory_section')
        self.unit0 = ItemFactory.create(parent=self.section0,
                                        display_name='New Unit')

        self.chapterchrome = ItemFactory.create(parent=self.course,
                                                display_name='Chrome')
        self.chromelesssection = ItemFactory.create(parent=self.chapterchrome,
                                                    display_name='chromeless',
                                                    chrome='none')
        self.accordionsection = ItemFactory.create(parent=self.chapterchrome,
                                                   display_name='accordion',
                                                   chrome='accordion')
        self.tabssection = ItemFactory.create(parent=self.chapterchrome,
                                              display_name='tabs',
                                              chrome='tabs')
        self.defaultchromesection = ItemFactory.create(
            parent=self.chapterchrome,
            display_name='defaultchrome',
        )
        self.fullchromesection = ItemFactory.create(parent=self.chapterchrome,
                                                    display_name='fullchrome',
                                                    chrome='accordion,tabs')
        self.tabtest = ItemFactory.create(parent=self.chapterchrome,
                                          display_name='progress_tab',
                                          default_tab='progress')

        # Create student accounts and activate them.
        for i in range(len(self.STUDENT_INFO)):
            email, password = self.STUDENT_INFO[i]
            username = '******'.format(i)
            self.create_account(username, email, password)
            self.activate_user(email)

        self.staff_user = GlobalStaffFactory()
Exemplo n.º 17
0
    def setUp(self):
        super(CertificatesInstructorApiTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.user = UserFactory()

        # Enable certificate generation
        self.certificate_exception_data = [
            dict(created="Wednesday, October 28, 2015",
                 notes="Test Notes for Test Certificate Exception",
                 user_email='',
                 user_id='',
                 user_name=unicode(self.user.username)),
        ]

        cache.clear()
        CertificateGenerationConfiguration.objects.create(enabled=True)
Exemplo n.º 18
0
    def setUp(self):
        super(CertificateInvalidationViewTests, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.enrolled_user_1 = UserFactory(
            username='******',
            email='*****@*****.**',
            first_name='Enrolled',
            last_name='Student',
        )
        self.enrolled_user_2 = UserFactory(
            username='******',
            email='*****@*****.**',
            first_name='Enrolled',
            last_name='Student',
        )

        self.not_enrolled_student = UserFactory(
            username='******',
            email='*****@*****.**',
            first_name='NotEnrolled',
            last_name='Student',
        )
        CourseEnrollment.enroll(self.enrolled_user_1, self.course.id)
        CourseEnrollment.enroll(self.enrolled_user_2, self.course.id)

        self.generated_certificate = GeneratedCertificateFactory.create(
            user=self.enrolled_user_1,
            course_id=self.course.id,
            status=CertificateStatuses.downloadable,
            mode='honor',
        )

        self.certificate_invalidation_data = dict(
            user=self.enrolled_user_1.username,
            notes=self.notes,
        )

        # Global staff can see the certificates section
        self.client.login(username=self.global_staff.username, password="******")
Exemplo n.º 19
0
    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)
Exemplo n.º 20
0
    def setUp(self):
        super(GenerateCertificatesInstructorApiTest, self).setUp()
        self.global_staff = GlobalStaffFactory()
        self.instructor = InstructorFactory(course_key=self.course.id)
        self.user = UserFactory()
        CourseEnrollment.enroll(self.user, self.course.id)
        certificate_exception = CertificateWhitelistFactory.create(
            user=self.user,
            course_id=self.course.id,
        )

        self.certificate_exception = dict(
            id=certificate_exception.id,
            user_name=certificate_exception.user.username,
            notes=certificate_exception.notes,
            user_email=certificate_exception.user.email,
            user_id=certificate_exception.user.id,
        )

        # Enable certificate generation
        cache.clear()
        CertificateGenerationConfiguration.objects.create(enabled=True)
        self.client.login(username=self.global_staff.username, password='******')
Exemplo n.º 21
0
    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()
Exemplo n.º 22
0
 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
Exemplo n.º 23
0
 def create_user(self):
     self.user = GlobalStaffFactory.create()
Exemplo n.º 24
0
 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
Exemplo n.º 25
0
 def create_user(self):
     self.user = GlobalStaffFactory.create()
Exemplo n.º 26
0
    def setUp(self):
        super(TestRecommender, self).setUp()

        self.course = CourseFactory.create(
            display_name='Recommender_Test_Course')
        self.chapter = ItemFactory.create(parent=self.course,
                                          display_name='Overview')
        self.section = ItemFactory.create(parent=self.chapter,
                                          display_name='Welcome')
        self.unit = ItemFactory.create(parent=self.section,
                                       display_name='New Unit')
        self.xblock = ItemFactory.create(parent=self.unit,
                                         category='recommender',
                                         display_name='recommender')
        self.xblock2 = ItemFactory.create(parent=self.unit,
                                          category='recommender',
                                          display_name='recommender_second')

        self.course_url = reverse('courseware_section',
                                  kwargs={
                                      'course_id':
                                      self.course.id.to_deprecated_string(),
                                      'chapter':
                                      'Overview',
                                      'section':
                                      'Welcome',
                                  })

        self.resource_urls = [
            ("https://courses.edx.org/courses/MITx/3.091X/"
             "2013_Fall/courseware/SP13_Week_4/"
             "SP13_Periodic_Trends_and_Bonding/"),
            ("https://courses.edx.org/courses/MITx/3.091X/"
             "2013_Fall/courseware/SP13_Week_4/SP13_Covalent_Bonding/")
        ]

        self.test_recommendations = {
            self.resource_urls[0]: {
                "title":
                "Covalent bonding and periodic trends",
                "url":
                self.resource_urls[0],
                "description": ("http://people.csail.mit.edu/swli/edx/"
                                "recommendation/img/videopage1.png"),
                "descriptionText": ("short description for Covalent bonding "
                                    "and periodic trends")
            },
            self.resource_urls[1]: {
                "title":
                "Polar covalent bonds and electronegativity",
                "url":
                self.resource_urls[1],
                "description": ("http://people.csail.mit.edu/swli/edx/"
                                "recommendation/img/videopage2.png"),
                "descriptionText": ("short description for Polar covalent "
                                    "bonds and electronegativity")
            }
        }

        for idx, student in enumerate(self.STUDENTS):
            username = "******".format(idx)
            self.create_account(username, student['email'],
                                student['password'])
            self.activate_user(student['email'])

        self.staff_user = GlobalStaffFactory()