예제 #1
0
 def test_start(self):
     zrobot = Zrobot('zrobot', data=self.valid_data)
     container = MagicMock()
     zrobot._get_container = MagicMock(return_value=container)
     patch('js9.j.clients.zos.sal.get_node', MagicMock()).start()
     patch('js9.j.clients.zos.sal.get_zerorobot', MagicMock()).start()
     zrobot.start()
     zrobot.state.check('actions', 'start', 'ok')
     container.schedule_action.assert_called_once_with('start')
예제 #2
0
 def test_already_installed_no_force(self):
     """
     Test installation when already installed without force option
     """
     zrobot = Zrobot('zrobot', data=self.valid_data)
     zrobot.state.set('actions', 'install', 'ok')
     zrobot.install()
     container = MagicMock()
     zrobot._get_container = MagicMock(return_value=container)
     container.schedule_action.assert_not_called()
예제 #3
0
 def test_install(self):
     """
     Test successfully creating zrobot
     """
     zrobot = Zrobot('zrobot', data=self.valid_data)
     container = MagicMock()
     zrobot._get_container = MagicMock(return_value=container)
     patch('js9.j.clients.zos.sal.get_node', MagicMock()).start()
     patch('js9.j.clients.zos.sal.get_zerorobot', MagicMock()).start()
     zrobot.install()
     zrobot.state.check('actions', 'install', 'ok')
     zrobot.state.check('actions', 'start', 'ok')
     container.schedule_action.assert_called_once_with('install')
예제 #4
0
 def test_already_installed_force(self):
     """
     Test installation when already installed with force option
     """
     zrobot = Zrobot('zrobot', data=self.valid_data)
     container = MagicMock()
     zrobot._get_container = MagicMock(return_value=container)
     patch('js9.j.clients.zos.sal.get_node', MagicMock()).start()
     patch('js9.j.clients.zos.sal.get_zerorobot', MagicMock()).start()
     zrobot.state.set('actions', 'install', 'ok')
     zrobot.install(True)
     zrobot.state.check('actions', 'install', 'ok')
     zrobot.state.check('actions', 'start', 'ok')
     container.schedule_action.assert_called_once_with('install')
예제 #5
0
 def test_install_with_sshkey(self):
     """
     Test installing while using an sshkey
     """
     zrobot = Zrobot('zrobot', data=self.valid_data)
     container = MagicMock()
     zrobot._get_container = MagicMock(return_value=container)
     container.container_sal = MagicMock()
     container_sal = container.container_sal
     patch('jumpscale.j.clients.zos.get',  MagicMock()).start()
     patch('jumpscale.j.clients.zrobot.get',  MagicMock()).start()
     zrobot.install()
     zrobot.state.check('actions', 'install', 'ok')
     zrobot.state.check('actions', 'start', 'ok')
     container.schedule_action.assert_called_once_with('install')
     container_sal.upload_content.assert_called_once_with(zrobot.sshkey_path, zrobot.data['sshkey'])