Fix ServiceTypeNotFound and MGMTDriverNotSpecified

These two exception classes are not coding correctly.
and It seems our unit test does not cover them.
So this patch adds two unit negative tests.

Change-Id: Ia02fac7bc644d849fb3409c72cd279957e44a3e7
Cloese-bug: 1515838
This commit is contained in:
gong yong sheng 2015-11-13 10:21:49 +08:00
parent 351ca2b629
commit 7d867dd7ed
3 changed files with 23 additions and 4 deletions

View File

@ -395,7 +395,7 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
raise vnfm.MGMTDriverNotSpecified()
if (not attributes.is_attr_set(service_types)):
LOG.debug(_('service types unspecified'))
raise vnfm.SeviceTypesNotSpecified()
raise vnfm.ServiceTypesNotSpecified()
with context.session.begin(subtransactions=True):
template_id = str(uuid.uuid4())

View File

@ -30,11 +30,15 @@ LOG = logging.getLogger(__name__)
class InfraDriverNotSpecified(exceptions.InvalidInput):
message = _('infra driver is not speicfied')
message = _('infra driver is not specified')
class MGMTDriverNotSpecified(exceptions.InvalidInput):
message = _('mgmt driver is not specified')
class ServiceTypesNotSpecified(exceptions.InvalidInput):
message = _('service types are not speicfied')
message = _('service types are not specified')
class DeviceTemplateInUse(exceptions.InUse):
@ -69,7 +73,7 @@ class DeviceTemplateNotFound(exceptions.NotFound):
message = _('device template %(device_tempalte_id)s could not be found')
class SeviceTypeNotFound(exceptions.NotFound):
class ServiceTypeNotFound(exceptions.NotFound):
message = _('service type %(service_type_id)s could not be found')

View File

@ -18,6 +18,7 @@ import uuid
from tacker import context
from tacker.db.vm import vm_db
from tacker.extensions import vnfm
from tacker.tests.unit.db import base as db_base
from tacker.tests.unit.db import utils
from tacker.vm import plugin
@ -116,6 +117,20 @@ class TestVNFMPlugin(db_base.SqlTestCase):
device_template=
mock.ANY)
def test_create_vnfd_no_service_types(self):
vnfd_obj = utils.get_dummy_vnfd_obj()
vnfd_obj['vnfd'].pop('service_types')
self.assertRaises(vnfm.ServiceTypesNotSpecified,
self.vnfm_plugin.create_vnfd,
self.context, vnfd_obj)
def test_create_vnfd_no_mgmt_driver(self):
vnfd_obj = utils.get_dummy_vnfd_obj()
vnfd_obj['vnfd'].pop('mgmt_driver')
self.assertRaises(vnfm.MGMTDriverNotSpecified,
self.vnfm_plugin.create_vnfd,
self.context, vnfd_obj)
def test_create_vnf(self):
self._insert_dummy_device_template()
vnf_obj = utils.get_dummy_vnf_obj()