Mock looping_call in metadata agent tests
Change-Id: Icb5146084730384bac1fb7d3176ce0cfcd565cc5 Closes-Bug: #1262089
This commit is contained in:
parent
c85a888098
commit
40b4f470dd
@ -308,7 +308,10 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
|
|||||||
super(TestUnixDomainMetadataProxy, self).setUp()
|
super(TestUnixDomainMetadataProxy, self).setUp()
|
||||||
self.cfg_p = mock.patch.object(agent, 'cfg')
|
self.cfg_p = mock.patch.object(agent, 'cfg')
|
||||||
self.cfg = self.cfg_p.start()
|
self.cfg = self.cfg_p.start()
|
||||||
self.addCleanup(self.cfg_p.stop)
|
looping_call_p = mock.patch(
|
||||||
|
'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall')
|
||||||
|
self.looping_mock = looping_call_p.start()
|
||||||
|
self.addCleanup(mock.patch.stopall)
|
||||||
self.cfg.CONF.metadata_proxy_socket = '/the/path'
|
self.cfg.CONF.metadata_proxy_socket = '/the/path'
|
||||||
|
|
||||||
def test_init_doesnot_exists(self):
|
def test_init_doesnot_exists(self):
|
||||||
@ -393,13 +396,11 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_init_state_reporting(self):
|
def test_init_state_reporting(self):
|
||||||
with mock.patch('neutron.openstack.common.loopingcall.'
|
with mock.patch('os.makedirs'):
|
||||||
'FixedIntervalLoopingCall') as loop_call:
|
proxy = agent.UnixDomainMetadataProxy(mock.Mock())
|
||||||
with mock.patch('os.makedirs'):
|
self.looping_mock.assert_called_once_with(proxy._report_state)
|
||||||
proxy = agent.UnixDomainMetadataProxy(mock.Mock())
|
self.looping_mock.return_value.start.assert_called_once_with(
|
||||||
loop_call.assert_called_once_with(proxy._report_state)
|
interval=mock.ANY)
|
||||||
loop_call.return_value.start.assert_called_once_with(
|
|
||||||
interval=mock.ANY)
|
|
||||||
|
|
||||||
def test_report_state(self):
|
def test_report_state(self):
|
||||||
with mock.patch('neutron.agent.rpc.PluginReportStateAPI') as state_api:
|
with mock.patch('neutron.agent.rpc.PluginReportStateAPI') as state_api:
|
||||||
|
Loading…
Reference in New Issue
Block a user