tests: don't restore stopped mock that is set in setUp()

setUp() will be called for each new test case, so there is no need to
explicitly restore the mock.

Change-Id: I92d41706df19d028269f074937343dd18aa140a0
This commit is contained in:
Ihar Hrachyshka 2015-01-14 16:22:52 +01:00
parent 2c94b10d74
commit bc2d612c48
1 changed files with 16 additions and 20 deletions

View File

@ -773,26 +773,22 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
cfg.CONF.set_override('log_file', 'test.log')
class_path = 'neutron.agent.linux.ip_lib.IPWrapper'
self.external_process_p.stop()
# Ensure the mock is restored if this test fail
try:
with mock.patch(class_path) as ip_wrapper:
self.dhcp.enable_isolated_metadata_proxy(network)
ip_wrapper.assert_has_calls([mock.call(
'sudo',
'qdhcp-12345678-1234-5678-1234567890ab'),
mock.call().netns.execute([
'neutron-ns-metadata-proxy',
mock.ANY,
mock.ANY,
'--router_id=forzanapoli',
mock.ANY,
mock.ANY,
'--debug',
('--log-file=neutron-ns-metadata-proxy-%s.log' %
network.id)], addl_env=None)
])
finally:
self.external_process_p.start()
with mock.patch(class_path) as ip_wrapper:
self.dhcp.enable_isolated_metadata_proxy(network)
ip_wrapper.assert_has_calls([mock.call(
'sudo',
'qdhcp-12345678-1234-5678-1234567890ab'),
mock.call().netns.execute([
'neutron-ns-metadata-proxy',
mock.ANY,
mock.ANY,
'--router_id=forzanapoli',
mock.ANY,
mock.ANY,
'--debug',
('--log-file=neutron-ns-metadata-proxy-%s.log' %
network.id)], addl_env=None)
])
def test_enable_isolated_metadata_proxy_with_metadata_network(self):
self._test_metadata_network(fake_meta_network)