summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-11-27 20:23:02 +0000
committerGerrit Code Review <review@openstack.org>2012-11-27 20:23:02 +0000
commit79d64e60552d5075e4347218c851f26dcd6ecc53 (patch)
tree9504068aa2b0f673f2d5fcea423d8fffea54fd9d /nova/tests
parentc3bb85861a23bdcdbf1f205075716e85e78d7e62 (diff)
parentc0daa695a4b880523e7c3d4d4d29d99f927e8bd9 (diff)
Merge "Add exceptions to baremetal/db/api"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/baremetal/__init__.py15
-rw-r--r--nova/tests/baremetal/db/test_bm_interface.py9
-rw-r--r--nova/tests/baremetal/db/test_bm_node.py13
3 files changed, 32 insertions, 5 deletions
diff --git a/nova/tests/baremetal/__init__.py b/nova/tests/baremetal/__init__.py
new file mode 100644
index 000000000..eef64faeb
--- /dev/null
+++ b/nova/tests/baremetal/__init__.py
@@ -0,0 +1,15 @@
+# Copyright (c) 2012 NTT DOCOMO, INC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+from nova.tests import *
diff --git a/nova/tests/baremetal/db/test_bm_interface.py b/nova/tests/baremetal/db/test_bm_interface.py
index 6aef437c1..9f051ac9b 100644
--- a/nova/tests/baremetal/db/test_bm_interface.py
+++ b/nova/tests/baremetal/db/test_bm_interface.py
@@ -42,6 +42,13 @@ class BareMetalInterfaceTestCase(base.BMDBTestCase):
pif2_id = db.bm_interface_create(self.context, 2, '22:22:22:22:22:22',
'0x2', 2)
db.bm_interface_set_vif_uuid(self.context, pif1_id, 'AAAA')
- self.assertRaises(exception.DBError,
+ self.assertRaises(exception.NovaException,
db.bm_interface_set_vif_uuid,
self.context, pif2_id, 'AAAA')
+
+ def test_vif_not_found(self):
+ pif_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
+ '0x1', 1)
+ self.assertRaises(exception.NovaException,
+ db.bm_interface_set_vif_uuid,
+ self.context, pif_id + 1, 'AAAA')
diff --git a/nova/tests/baremetal/db/test_bm_node.py b/nova/tests/baremetal/db/test_bm_node.py
index 062b209a6..8cac38378 100644
--- a/nova/tests/baremetal/db/test_bm_node.py
+++ b/nova/tests/baremetal/db/test_bm_node.py
@@ -17,6 +17,7 @@
Bare-Metal DB testcase for BareMetalNode
"""
+from nova import exception
from nova.tests.baremetal.db import base
from nova.tests.baremetal.db import utils
from nova.virt.baremetal import db
@@ -67,8 +68,10 @@ class BareMetalNodesTestCase(base.BMDBTestCase):
r = db.bm_node_get(self.context, self.ids[1])
self.assertEquals(r['pm_address'], '1')
- r = db.bm_node_get(self.context, -1)
- self.assertTrue(r is None)
+ self.assertRaises(
+ exception.InstanceNotFound,
+ db.bm_node_get,
+ self.context, -1)
def test_get_by_service_host(self):
self._create_nodes()
@@ -97,8 +100,10 @@ class BareMetalNodesTestCase(base.BMDBTestCase):
db.bm_node_destroy(self.context, self.ids[0])
- r = db.bm_node_get(self.context, self.ids[0])
- self.assertTrue(r is None)
+ self.assertRaises(
+ exception.InstanceNotFound,
+ db.bm_node_get,
+ self.context, self.ids[0])
r = db.bm_node_get_all(self.context)
self.assertEquals(len(r), 5)