summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2011-06-03 01:10:45 +0000
committerTarmac <>2011-06-03 01:10:45 +0000
commit33a6e766742fdb768defe66d714d5f7a71ee7e5f (patch)
tree9fa525b3625eb69974931e8adcd54f3a50b91c49 /nova
parentf3e3b4b0fb1fb948f0fa5042ab854c00a710a6c2 (diff)
parentae1842174f4b079c8d84b32ddad4df1b7ff29bec (diff)
Tests that all exceptions can be raised properly, and fix the couple of instances where they couldn't be constructed due to typos.
Diffstat (limited to 'nova')
-rw-r--r--nova/exception.py4
-rw-r--r--nova/tests/test_misc.py13
2 files changed, 15 insertions, 2 deletions
diff --git a/nova/exception.py b/nova/exception.py
index d3d58f3b2..5b824bba6 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -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):
diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py
index cf8f4c05e..c5875a843 100644
--- a/nova/tests/test_misc.py
+++ b/nova/tests/test_misc.py
@@ -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__) + '/../../')