self.make_msg('report_state',
agent_state={'agent_state':
agent_state},
- time=timeutils.utcnow()),
+ time=timeutils.strtime()),
topic=self.topic)
self._test_rpc_call('tunnel_sync')
+class AgentPluginReportState(base.BaseTestCase):
+ def test_plugin_report_state(self):
+ topic = 'test'
+ reportStateAPI = rpc.PluginReportStateAPI(topic)
+ expected_agent_state = {'agent': 'test'}
+ with mock.patch.object(reportStateAPI, 'call') as call:
+ ctxt = context.RequestContext('fake_user', 'fake_project')
+ reportStateAPI.report_state(ctxt, expected_agent_state)
+ self.assertEqual(call.call_args[0][0], ctxt)
+ self.assertEqual(call.call_args[0][1]['method'],
+ 'report_state')
+ self.assertEqual(call.call_args[0][1]['args']['agent_state'],
+ {'agent_state': expected_agent_state})
+ self.assertIsInstance(call.call_args[0][1]['args']['time'],
+ str)
+ self.assertEqual(call.call_args[1]['topic'], topic)
+
+
class AgentRPCMethods(base.BaseTestCase):
def test_create_consumers(self):
dispatcher = mock.Mock()