Fix TypeError: <MagicMock name='LinuxBridgeManager().local_ip'
This patch fixes an error that does not result in a test failure but causes the following error to be logged in the test logs: TypeError: <MagicMock name='LinuxBridgeManager().local_ip' id='666599248'> is not JSON serializable Related-Bug: #1234857 Change-Id: I65cdd997745d8b760031f8f32e3c10682ad2288e
This commit is contained in:
parent
39f6bba5c4
commit
e07d536476
@ -97,11 +97,6 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
|
||||
super(TestLinuxBridgeAgent, self).setUp()
|
||||
cfg.CONF.set_override('rpc_backend',
|
||||
'neutron.openstack.common.rpc.impl_fake')
|
||||
self.lbmgr_patcher = mock.patch('neutron.plugins.linuxbridge.agent.'
|
||||
'linuxbridge_neutron_agent.'
|
||||
'LinuxBridgeManager')
|
||||
self.lbmgr_mock = self.lbmgr_patcher.start()
|
||||
self.addCleanup(self.lbmgr_patcher.stop)
|
||||
self.execute_p = mock.patch.object(ip_lib.IPWrapper, '_execute')
|
||||
self.execute = self.execute_p.start()
|
||||
self.addCleanup(self.execute_p.stop)
|
||||
@ -113,8 +108,6 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
|
||||
self.get_mac.return_value = '00:00:00:00:00:01'
|
||||
|
||||
def test_update_devices_failed(self):
|
||||
lbmgr_instance = self.lbmgr_mock.return_value
|
||||
lbmgr_instance.update_devices.side_effect = RuntimeError
|
||||
agent = linuxbridge_neutron_agent.LinuxBridgeNeutronAgentRPC({},
|
||||
0,
|
||||
None)
|
||||
@ -125,8 +118,11 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
|
||||
raise_exception[0] += 1
|
||||
else:
|
||||
raise RuntimeError()
|
||||
|
||||
with mock.patch.object(linuxbridge_neutron_agent.LOG, 'info') as log:
|
||||
with mock.patch.object(agent.br_mgr,
|
||||
"update_devices") as update_devices:
|
||||
update_devices.side_effect = RuntimeError
|
||||
with mock.patch.object(linuxbridge_neutron_agent.LOG,
|
||||
'info') as log:
|
||||
log.side_effect = info_mock
|
||||
with testtools.ExpectedException(RuntimeError):
|
||||
agent.daemon_loop()
|
||||
@ -134,8 +130,6 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
|
||||
|
||||
def test_process_network_devices_failed(self):
|
||||
device_info = {'current': [1, 2, 3]}
|
||||
lbmgr_instance = self.lbmgr_mock.return_value
|
||||
lbmgr_instance.update_devices.return_value = device_info
|
||||
agent = linuxbridge_neutron_agent.LinuxBridgeNeutronAgentRPC({},
|
||||
0,
|
||||
None)
|
||||
@ -147,6 +141,9 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
|
||||
else:
|
||||
raise RuntimeError()
|
||||
|
||||
with mock.patch.object(agent.br_mgr,
|
||||
"update_devices") as update_devices:
|
||||
update_devices.side_effect = device_info
|
||||
with contextlib.nested(
|
||||
mock.patch.object(linuxbridge_neutron_agent.LOG, 'info'),
|
||||
mock.patch.object(agent, 'process_network_devices')
|
||||
|
Loading…
Reference in New Issue
Block a user