示例#1
0
    def test_is_current_user_admin(self):
        with patch('apps.auth.get_user', return_value={}):
            self.assertFalse(is_current_user_admin())

        with patch('apps.auth.get_user',
                   return_value={'user_type': 'administrator'}):
            self.assertTrue(is_current_user_admin())
示例#2
0
    def test_is_current_user_admin(self):
        with patch("apps.auth.get_user", return_value={}):
            self.assertFalse(is_current_user_admin())

        with patch("apps.auth.get_user",
                   return_value={"user_type": "administrator"}):
            self.assertTrue(is_current_user_admin())
示例#3
0
 def is_authorizes(self, user):
     return is_current_user_admin()
示例#4
0
    def test_is_current_user_admin(self):
        with patch('apps.auth.get_user', return_value={}):
            self.assertFalse(is_current_user_admin())

        with patch('apps.auth.get_user', return_value={'user_type': 'administrator'}):
            self.assertTrue(is_current_user_admin())
 def is_authorizes(self, user):
     return is_current_user_admin()
示例#6
0
 def _validate_administrator(self, operation):
     if not is_current_user_admin():
         raise SuperdeskApiError.badRequestError(message=_(
             "Only administrator user can {operation} the message").format(
                 operation=operation))