Ejemplo n.º 1
0
 def testAnonymousDeniedAccess(self):
     """Tests that logged-out users are denied access."""
     access_checker = access.ProgramAdministratorAccessChecker()
     with self.assertRaises(exception.UserError) as context:
         access_checker.checkAccess(self.data, None)
     self.assertEqual(context.exception.message,
                      access._MESSAGE_NOT_PROGRAM_ADMINISTRATOR)
Ejemplo n.º 2
0
    def testProgramAdministratorsAllowedAccess(self):
        """Tests that a program administrator is allowed access."""
        # make the user a program administrator
        self.user.host_for = [ndb.Key.from_old_key(self.program.key())]
        self.user.put()

        access_checker = access.ProgramAdministratorAccessChecker()
        access_checker.checkAccess(self.data, None)
Ejemplo n.º 3
0
    def testStudentDeniedAccess(self):
        """Tests that students are denied access."""
        # seed a profile who is a student
        profile_utils.seedNDBStudent(self.program, user=self.user)

        access_checker = access.ProgramAdministratorAccessChecker()
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.message,
                         access._MESSAGE_NOT_PROGRAM_ADMINISTRATOR)
Ejemplo n.º 4
0
    def testMentorDeniedAccess(self):
        """Tests that a mentor is denied access."""
        # seed a profile who is a mentor
        org = org_utils.seedOrganization(self.program.key())
        profile_utils.seedNDBProfile(self.program.key(),
                                     user=self.user,
                                     mentor_for=[org.key])

        access_checker = access.ProgramAdministratorAccessChecker()
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.message,
                         access._MESSAGE_NOT_PROGRAM_ADMINISTRATOR)