From: Jenkins Date: Sun, 23 Feb 2014 23:51:27 +0000 (+0000) Subject: Merge "Improve unit test coverage for Cisco plugin model code" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=07a467da2c0372c8b18e5a670e97f50545c12385;p=openstack-build%2Fneutron-build.git Merge "Improve unit test coverage for Cisco plugin model code" --- 07a467da2c0372c8b18e5a670e97f50545c12385 diff --cc neutron/plugins/cisco/models/virt_phy_sw_v2.py index 223df995a,36e196097..1e8d125e4 --- a/neutron/plugins/cisco/models/virt_phy_sw_v2.py +++ b/neutron/plugins/cisco/models/virt_phy_sw_v2.py @@@ -47,9 -47,9 +47,8 @@@ class VirtualPhysicalSwitchModelV2(neut following topology: One or more servers to a nexus switch. """ - MANAGE_STATE = True __native_bulk_support = True supported_extension_aliases = ["provider", "binding"] - _plugins = {} _methods_to_delegate = ['create_network_bulk', 'get_network', 'get_networks', 'create_port_bulk', diff --cc neutron/plugins/cisco/network_plugin.py index 5097082b4,c27a4c151..7d500a3d5 --- a/neutron/plugins/cisco/network_plugin.py +++ b/neutron/plugins/cisco/network_plugin.py @@@ -43,24 -48,28 +43,27 @@@ class PluginV2(db_base_plugin_v2.Neutro 'create_subnet', 'delete_subnet', 'update_subnet', 'get_subnet', 'get_subnets', ] - _master = True CISCO_FAULT_MAP = { + cexc.CredentialAlreadyExists: wexc.HTTPBadRequest, + cexc.CredentialNameNotFound: wexc.HTTPNotFound, + cexc.CredentialNotFound: wexc.HTTPNotFound, cexc.NetworkSegmentIDNotFound: wexc.HTTPNotFound, - cexc.NoMoreNics: wexc.HTTPBadRequest, cexc.NetworkVlanBindingAlreadyExists: wexc.HTTPBadRequest, - cexc.VlanIDNotFound: wexc.HTTPNotFound, - cexc.VlanIDNotAvailable: wexc.HTTPNotFound, - cexc.QosNotFound: wexc.HTTPNotFound, - cexc.QosNameAlreadyExists: wexc.HTTPBadRequest, - cexc.CredentialNotFound: wexc.HTTPNotFound, - cexc.CredentialNameNotFound: wexc.HTTPNotFound, - cexc.CredentialAlreadyExists: wexc.HTTPBadRequest, cexc.NexusComputeHostNotConfigured: wexc.HTTPNotFound, - cexc.NexusConnectFailed: wexc.HTTPServiceUnavailable, cexc.NexusConfigFailed: wexc.HTTPBadRequest, + cexc.NexusConnectFailed: wexc.HTTPServiceUnavailable, cexc.NexusPortBindingNotFound: wexc.HTTPNotFound, + cexc.NoMoreNics: wexc.HTTPBadRequest, + cexc.PortIdForNexusSvi: wexc.HTTPBadRequest, cexc.PortVnicBindingAlreadyExists: wexc.HTTPBadRequest, - cexc.PortVnicNotFound: wexc.HTTPNotFound} + cexc.PortVnicNotFound: wexc.HTTPNotFound, + cexc.QosNameAlreadyExists: wexc.HTTPBadRequest, + cexc.QosNotFound: wexc.HTTPNotFound, + cexc.SubnetNotSpecified: wexc.HTTPBadRequest, + cexc.VlanIDNotAvailable: wexc.HTTPNotFound, + cexc.VlanIDNotFound: wexc.HTTPNotFound, + } def __init__(self): """Load the model class.""" diff --cc neutron/tests/unit/cisco/test_network_plugin.py index 762d7b2e7,c7d8bbd75..1d94011af --- a/neutron/tests/unit/cisco/test_network_plugin.py +++ b/neutron/tests/unit/cisco/test_network_plugin.py @@@ -204,14 -187,29 +204,31 @@@ class CiscoNetworkPluginV2TestCase(test vlan_created == vlan_creation_expected and add_appears == add_keyword_expected) - def _is_vlan_unconfigured(self, vlan_deletion_expected=True): - vlan_deleted = self._is_in_last_nexus_cfg( + def _is_vlan_unconfigured(self, vlan_deletion_expected=True, + vlan_untrunk_expected=True): + vlan_deleted = self._is_in_nexus_cfg( ['no', 'vlan', 'vlan-id-create-delete']) - return (self._is_in_nexus_cfg(['allowed', 'vlan', 'remove']) and - vlan_deleted == vlan_deletion_expected) + vlan_untrunked = self._is_in_nexus_cfg(['allowed', 'vlan', 'remove']) + return (vlan_deleted == vlan_deletion_expected and + vlan_untrunked == vlan_untrunk_expected) + def _assertExpectedHTTP(self, status, exc): + """Confirm that an HTTP status corresponds to an expected exception. + + Confirm that an HTTP status which has been returned for an + neutron API request matches the HTTP status corresponding + to an expected exception. + + :param status: HTTP status + :param exc: Expected exception + + """ + if exc in base.FAULT_MAP: + expected_http = base.FAULT_MAP[exc].code + else: + expected_http = wexc.HTTPInternalServerError.code + self.assertEqual(status, expected_http) + class TestCiscoBasicGet(CiscoNetworkPluginV2TestCase, test_db_plugin.TestBasicGet):