Tests to assure all exceptions can be raised as well as fixing NotAuthorized
This commit is contained in:
@@ -65,7 +65,7 @@ class BuildInProgress(Error):
|
||||
|
||||
class DBError(Error):
|
||||
"""Wraps an implementation specific exception."""
|
||||
def __init__(self, inner_exception):
|
||||
def __init__(self, inner_exception=None):
|
||||
self.inner_exception = inner_exception
|
||||
super(DBError, self).__init__(str(inner_exception))
|
||||
|
||||
@@ -122,7 +122,7 @@ class NotAuthorized(NovaException):
|
||||
message = _("Not authorized.")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NotFound, self).__init__(**kwargs)
|
||||
super(NotAuthorized, self).__init__(**kwargs)
|
||||
|
||||
|
||||
class AdminRequired(NotAuthorized):
|
||||
|
||||
@@ -21,11 +21,24 @@ import select
|
||||
from eventlet import greenpool
|
||||
from eventlet import greenthread
|
||||
|
||||
from nova import exception
|
||||
from nova import test
|
||||
from nova import utils
|
||||
from nova.utils import parse_mailmap, str_dict_replace
|
||||
|
||||
|
||||
class ExceptionTestCase(test.TestCase):
|
||||
@staticmethod
|
||||
def _raise_exc(exc):
|
||||
raise exc()
|
||||
|
||||
def test_exceptions_raise(self):
|
||||
for name in dir(exception):
|
||||
exc = getattr(exception, name)
|
||||
if isinstance(exc, type):
|
||||
self.assertRaises(exc, self._raise_exc, exc)
|
||||
|
||||
|
||||
class ProjectTestCase(test.TestCase):
|
||||
def test_authors_up_to_date(self):
|
||||
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
|
||||
|
||||
Reference in New Issue
Block a user