def test_monitor_service_ok(self): """ Test monitor when container service exists """ zrobot = Zrobot('zrobot', data=self.valid_data) zrobot.api.services.get = MagicMock() patch('js9.j.clients.zos.sal.get_zerorobot', MagicMock()).start() zrobot.state.set('actions', 'install', 'ok') zrobot.state.set('actions', 'start', 'ok') zrobot._monitor() zrobot.state.check('status', 'running', 'ok')
def test_monitor_service_not_found(self): """ Test monitor when service container can't be found """ zrobot = Zrobot('zrobot', data=self.valid_data) zrobot.api.services.get = MagicMock(side_effect=scol.ServiceNotFoundError()) patch('jumpscale.j.clients.zrobot.get', MagicMock()).start() zrobot.state.set('actions', 'install', 'ok') zrobot.state.set('actions', 'start', 'ok') zrobot.state.delete = MagicMock(return_value=True) zrobot.start = MagicMock() zrobot._monitor() zrobot.state.delete.assert_called_with('status', 'running') zrobot.start.assert_called_once_with()