]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove unnecessary MagicMocks in cisco unit tests
authorKevin Benton <blak111@gmail.com>
Fri, 30 May 2014 03:49:48 +0000 (20:49 -0700)
committerKevin Benton <blak111@gmail.com>
Fri, 30 May 2014 03:49:48 +0000 (20:49 -0700)
Two patches that just return static data never have
assertions made on the MagicMocks generated. This
replaces the magicmocks with lambdas to make the code
easier to read and to get a minor performance gain.

Change-Id: I064c57a66a0f7a8e3080f39cf48bd4b67cf304e3
Partial-Bug: #1316401

neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py

index 12973a38381304413d31f416194270e805a08aad..ad45b0910cae1e8f6d35615b64396bf8a9dec33b 100644 (file)
@@ -201,17 +201,13 @@ class N1kvPluginTestCase(test_plugin.NeutronDbPluginV2TestCase):
         # in the background.
 
         # Return a dummy VSM IP address
-        get_vsm_hosts_patcher = mock.patch(n1kv_client.__name__ +
-                                           ".Client._get_vsm_hosts")
-        fake_get_vsm_hosts = get_vsm_hosts_patcher.start()
-        fake_get_vsm_hosts.return_value = ["127.0.0.1"]
+        mock.patch(n1kv_client.__name__ + ".Client._get_vsm_hosts",
+                   new=lambda self: "127.0.0.1").start()
 
         # Return dummy user profiles
-        get_cred_name_patcher = mock.patch(cdb.__name__ +
-                                           ".get_credential_name")
-        fake_get_cred_name = get_cred_name_patcher.start()
-        fake_get_cred_name.return_value = {"user_name": "admin",
-                                           "password": "admin_password"}
+        mock.patch(cdb.__name__ + ".get_credential_name",
+                   new=lambda self: {"user_name": "admin",
+                                     "password": "admin_password"}).start()
 
         n1kv_neutron_plugin.N1kvNeutronPluginV2._setup_vsm = _fake_setup_vsm