Пример #1
0
 def test_unix_set_prompt_expection2(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.execute = MagicMock(return_value=1)
     uobject.prompt = MagicMock(return_value="TOBY")
     type(uobject).response = PropertyMock(side_effect=['vsh $'])
     self.assertRaises(Exception,
                       lambda: UnixHost.set_prompt(uobject, prompt='TOBY'))
Пример #2
0
 def test_unix_su_user_password(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.execute = MagicMock(return_value=1)
     uobject.prompt = '$ '
     uobject.set_prompt = MagicMock
     uobject.shell.return_value.response.return_value = "root"
     self.assertTrue(UnixHost.su(uobject, password='******'))
Пример #3
0
 def test_unix_disconnect(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.connect_mode = 'ssh'
     uobject.handle = MagicMock()
     uobject.log_handle = MagicMock()
     uobject.close_obj = MagicMock()
     self.assertTrue(UnixHost.close(uobject))
Пример #4
0
 def test_unix_execute(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.handle = MagicMock()
     uobject.prompt = MagicMock(return_value='%')
     uobject.handle.execute = MagicMock(return_value='regress')
     uobject.shell_timeout = 60
     self.assertEqual(UnixHost.execute(uobject, command='ls'), 'regress')
Пример #5
0
 def test_unix_reboot(self, patch1):
     uobject = MagicMock(spec=UnixHost)
     uobject.su = MagicMock()
     uobject.shell = MagicMock(return_value=-1)
     uobject.is_alive = MagicMock(return_value=False)
     uobject.host = 'dummy'
     uobject.reconnect = MagicMock()
     self.assertTrue(UnixHost.reboot(uobject))
Пример #6
0
 def test_unix_su_exception(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.execute = MagicMock(side_effect=[1, 1])
     uobject.prompt = '$ '
     uobject.set_prompt = MagicMock
     uobject.shell = MagicMock(return_value=-1)
     print('toto')
     self.assertRaises(Exception,
                       lambda: UnixHost.su(uobject, password='******'))
Пример #7
0
 def test_unix_su(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.execute = MagicMock(return_value=1)
     uobject.get_su_credentials = MagicMock(return_value=('root',
                                                          'Embe1mpls'))
     uobject.prompt = '$ '
     uobject.set_prompt = MagicMock
     uobject.shell.return_value.response.return_value = "root"
     self.assertTrue(UnixHost.su(uobject))
Пример #8
0
 def test_unix_set_prompt_csh(self):
     uobject = MagicMock(spec=UnixHost)
     uobject.execute = MagicMock(return_value=1)
     uobject.prompt = MagicMock(return_value="TOBY")
     type(uobject).response = PropertyMock(side_effect=['csh $'])
     self.assertTrue(UnixHost.set_prompt(uobject, prompt='TOBY'))
Пример #9
0
 def test_unix_close2(self):
     self.test_unix_disconnect2()
     uobject = MagicMock(spec=UnixHost)
     self.assertTrue(UnixHost.close(uobject))