]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Drop sudo requirement from a unit test
authorRussell Bryant <rbryant@redhat.com>
Tue, 25 Nov 2014 18:06:46 +0000 (18:06 +0000)
committerRussell Bryant <rbryant@redhat.com>
Tue, 25 Nov 2014 18:06:46 +0000 (18:06 +0000)
I noticed while working on some other stuff that a unit test was
prompting me for my sudo password.  I narrowed it down to the
offending test case and fixed it by mocking out the execute util, as
is done in several other places in these tests.

Change-Id: I93c6cdb8a26d3be5df5386091dc70a240ab7c190
Closes-bug: #1396276

neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py

index c39f1cdc18a5c3b6baa06c6abff0b59cdd2b4806..3874a3c439f5e210b085a10c470edf6053eb5ec4 100644 (file)
@@ -565,10 +565,12 @@ class TestOvsNeutronAgent(base.BaseTestCase):
         # Raise a timeout every time until we give up, currently 5 tries
         self._setup_for_dvr_test()
         self.agent.dvr_agent.dvr_mac_address = None
-        with mock.patch.object(self.agent.dvr_agent.plugin_rpc,
-                               'get_dvr_mac_address_by_host',
-                               side_effect=raise_timeout):
-
+        with contextlib.nested(
+                mock.patch.object(self.agent.dvr_agent.plugin_rpc,
+                                 'get_dvr_mac_address_by_host',
+                                 side_effect=raise_timeout),
+                mock.patch.object(utils, "execute"),
+        ) as (rpc_mock, execute_mock):
             self.agent.dvr_agent.get_dvr_mac_address()
             self.assertIsNone(self.agent.dvr_agent.dvr_mac_address)
             self.assertFalse(self.agent.dvr_agent.in_distributed_mode())