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 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()
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))