]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Improve unit test coverage for Cisco plugin model code"
authorJenkins <jenkins@review.openstack.org>
Sun, 23 Feb 2014 23:51:27 +0000 (23:51 +0000)
committerGerrit Code Review <review@openstack.org>
Sun, 23 Feb 2014 23:51:27 +0000 (23:51 +0000)
1  2 
neutron/plugins/cisco/models/virt_phy_sw_v2.py
neutron/plugins/cisco/network_plugin.py
neutron/tests/unit/cisco/test_network_plugin.py

index 223df995a49c175d519716496ef6e0b0a8a2db64,36e196097d7cd014fb0c003d52e0c19de4cd5e67..1e8d125e4fec83e781b7a8a19273ebe731869bdf
@@@ -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',
index 5097082b4680fcf4c67c7a2672cba8179bd40647,c27a4c1518da5361d67e08d23abd3c0245937a96..7d500a3d590f68d7f0579a4944808a4e64b1af4c
@@@ -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."""
index 762d7b2e7200a486f7fd30d1bda4bd3d79c32692,c7d8bbd759597726df258c470c6b41b4c9064846..1d94011af8c602d203e502aad48ab75163ffc210
@@@ -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):