예제 #1
0
    def runTest(self):
        # Make sure user starts off with no administrator priviliges
        self.assertFalse(self.user.is_staff)
        self.assertFalse(self.user.is_superuser)
        self.assertFalse(
            UserBit.objects.UserHasPerms(user=self.user,
                                         qsc=GetNode('Q'),
                                         verb=GetNode('V/Administer')))
        self.assertFalse(
            UserBit.objects.UserHasPerms(
                user=self.user,
                qsc=GetNode('Q'),
                verb=GetNode('V/Flags/UserRole/Administrator')))

        # Now make admin_test into an admin using make_admin
        make_user_admin(self.user)

        # Make sure user now has administrator privileges
        self.assertTrue(self.user.is_staff)
        self.assertTrue(self.user.is_superuser)
        self.assertTrue(
            UserBit.objects.UserHasPerms(user=self.user,
                                         qsc=GetNode('Q'),
                                         verb=GetNode('V/Administer')))
        self.assertTrue(
            UserBit.objects.UserHasPerms(
                user=self.user,
                qsc=GetNode('Q'),
                verb=GetNode('V/Flags/UserRole/Administrator')))

        # Make sure that an unprivileged access to /myesp/makeadmin/ returns 403 Forbidden
        response = self.client.get('/myesp/makeadmin/')
        self.assertEqual(response.status_code, 403)
예제 #2
0
    def testGradeChange(self):
        # Create the admin user
        adminUser, c1 = ESPUser.objects.get_or_create(username='******')
        adminUser.set_password('password')
        make_user_admin(adminUser)
        # Create the student user
        studentUser, c2 = ESPUser.objects.get_or_create(username='******')
        # Make it a student
        role_bit, created = UserBit.objects.get_or_create(user=studentUser, qsc=GetNode('Q'), verb=GetNode('V/Flags/UserRole/Student'), recursive=False)
        # Give it a starting grade
        student_studentinfo = StudentInfo(user=studentUser, graduation_year=ESPUser.YOGFromGrade(9))
        student_studentinfo.save()
        student_regprofile = RegistrationProfile(user=studentUser, student_info=student_studentinfo, most_recent_profile=True)
        student_regprofile.save()
        # Check that the grade starts at 9
        self.failUnless(studentUser.getGrade() == 9)

        # Login the admin
        self.failUnless(self.client.login(username="******", password="******"))

        testGrade = 11
        curYear = ESPUser.current_schoolyear()
        gradYear = curYear + (12 - testGrade)
        self.client.get("/manage/userview?username=student&graduation_year="+str(gradYear))
        self.failUnless(studentUser.getGrade() == testGrade, "Grades don't match: %s %s" % (studentUser.getGrade(), testGrade))

        # Clean up
        if (c1):
            adminUser.delete()
        if (c2):
            studentUser.delete()
예제 #3
0
    def runTest(self):
        # Make sure user starts off with no administrator priviliges
        self.assertFalse(self.user.is_staff)
        self.assertFalse(self.user.is_superuser)
        self.assertFalse(
            self.user.groups.filter(name="Administrator").exists())

        # Now make admin_test into an admin using make_admin
        make_user_admin(self.user)

        # Make sure user now has administrator privileges
        self.assertTrue(self.user.is_staff)
        self.assertTrue(self.user.is_superuser)
        self.assertTrue(self.user.groups.filter(name="Administrator").exists())

        # Make sure that an unprivileged access to /myesp/makeadmin/ returns a redirect to the login page
        response = self.client.get('/myesp/makeadmin/')
        self.assertRedirects(response,
                             '/accounts/login/?next=/myesp/makeadmin/')
예제 #4
0
    def setUp(self):
        modules = []
        modules.append(ProgramModule.objects.get(handler='TeacherClassRegModule').id)
        modules.append(ProgramModule.objects.get(handler='StudentClassRegModule').id)
        modules.append(ProgramModule.objects.get(handler='StudentRegCore').id)
        modules.append(ProgramModule.objects.get(handler='AdminCore').id)
        
        super(RegistrationTypeManagementTest, self).setUp(modules=modules)
        self.schedule_randomly()

        # Create registration types
        self.testRT = "TestType"
        RegistrationType.objects.get_or_create(name=self.testRT)
        RegistrationType.objects.get_or_create(name='Enrolled')


        # Create an admin account
        self.adminUser, created = ESPUser.objects.get_or_create(username='******')
        self.adminUser.set_password('password')
        make_user_admin(self.adminUser)