diff --git a/nova/tests/baremetal/__init__.py b/nova/tests/baremetal/__init__.py new file mode 100644 index 00000000..eef64fae --- /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 6aef437c..9f051ac9 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 062b209a..8cac3837 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)