def test_init(self): disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) self.assertEqual(self.thm, disp.TG) self.assertEqual('1234', disp.engine_id) self.assertEqual('TOPIC', disp.topic) self.assertEqual('1', disp.version)
def test_start_action(self, mock_start): disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) disp.start_action(self.context, action_id='FOO') mock_start.assert_called_once_with('1234', 'FOO') mock_start.reset_mock() disp.start_action(self.context) mock_start.assert_called_once_with('1234', None)
def test_start(self, mock_target, mock_server): mock_server.return_value = mock.Mock() mock_target.return_value = mock.Mock() disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) disp.start() mock_target.assert_called_once_with(server='1234', topic='TOPIC', version='1') the_target = mock_target.return_value mock_server.assert_called_once_with(the_target, disp) the_server = mock_server.return_value the_server.start.assert_called_once_with()
def test_resume_action(self, mock_resume): disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) disp.resume_action(self.context, action_id='FOO') mock_resume.assert_called_once_with('FOO')
def test_suspend_action(self, mock_suspend): disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) disp.suspend_action(self.context, action_id='FOO') mock_suspend.assert_called_once_with('FOO')
def test_listening(self): disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) result = disp.listening(self.context) self.assertTrue(result)
def test_stop(self, mock_stop): disp = dispatcher.Dispatcher(self.svc, 'TOPIC', '1', self.thm) disp.stop() mock_stop.assert_called_once_with(True)