Merge "Add exceptions to baremetal/db/api"

This commit is contained in:
Jenkins
2012-11-27 20:23:02 +00:00
committed by Gerrit Code Review
3 changed files with 32 additions and 5 deletions

View File

@@ -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 *

View File

@@ -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')

View File

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