]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixed TypeError when creating MlnxException
authorRoey Chen <roeyc@mellanox.com>
Tue, 25 Mar 2014 11:56:59 +0000 (13:56 +0200)
committerRoey Chen <roeyc@mellanox.com>
Tue, 25 Mar 2014 14:43:30 +0000 (16:43 +0200)
MlnxException expect a 'err_msg' keyword argument.

Change-Id: I4570219c0a6a466391b43cbdaa5372b85566c421
Closes-Bug: #1283990
Signe-off-by: Roey Chen <roeyc@mellanox.com>
neutron/plugins/mlnx/agent/eswitch_neutron_agent.py
neutron/tests/unit/mlnx/test_mlnx_neutron_agent.py

index 611290b990b7462419ac2a2f1bcc942a2851da62..201692ce91f82b0455c976de0961923290528928 100644 (file)
@@ -57,7 +57,7 @@ class EswitchManager(object):
         err_msg = _("Agent cache inconsistency - port id "
                     "is not stored for %s") % port_mac
         LOG.error(err_msg)
-        raise exceptions.MlnxException(err_msg)
+        raise exceptions.MlnxException(err_msg=err_msg)
 
     def get_vnics_mac(self):
         return set(self.utils.get_attached_vnics().keys())
index a1c60de3c0265a330376808853c36fe19ebb54c7..7191f0b38c9b580d1e704b4a686a0148a8daa14e 100644 (file)
@@ -19,12 +19,34 @@ import contextlib
 
 import mock
 from oslo.config import cfg
+import testtools
 
 from neutron.plugins.mlnx.agent import eswitch_neutron_agent
 from neutron.plugins.mlnx.agent import utils
+from neutron.plugins.mlnx.common import exceptions
 from neutron.tests import base
 
 
+class TestEswichManager(base.BaseTestCase):
+
+    def setUp(self):
+        super(TestEswichManager, self).setUp()
+
+        class MockEswitchUtils(object):
+            def __init__(self, endpoint, timeout):
+                pass
+
+        mock.patch('neutron.plugins.mlnx.agent.utils.EswitchManager',
+                   new=MockEswitchUtils)
+
+        with mock.patch.object(utils, 'zmq'):
+            self.manager = eswitch_neutron_agent.EswitchManager({}, None, None)
+
+    def test_get_not_exist_port_id(self):
+        with testtools.ExpectedException(exceptions.MlnxException):
+            self.manager.get_port_id_by_mac('no-such-mac')
+
+
 class TestEswitchAgent(base.BaseTestCase):
 
     def setUp(self):