def test_unix_reconnect(self, patch1, patch2, patch3): uobject = MagicMock(spec=UnixHost) uobject.prompt = MagicMock(return_value='%') uobject.host = 'dummy' uobject.user = '******' uobject.password = '******' uobject.connect_mode = 'ssh' uobject._kwargs = { 'user': '******', 'password': '******', 'ssh_key_file': 'dummy' } uobject.handle = MagicMock() uobject.set_prompt = MagicMock() self.assertTrue(UnixHost.reconnect(uobject)) uobject.handle.client.get_transport.return_value.isAlive.return_value = False self.assertTrue(UnixHost.reconnect(uobject))
def test_unix_reconnect_exception2(self, patch1, patch2, patch3): uobject = MagicMock(spec=UnixHost) uobject.prompt = MagicMock(return_value='%') uobject.host = 'dummy' uobject.user = '******' uobject.password = '******' uobject.connect_mode = 'ssh' uobject.handle = MagicMock() uobject.set_prompt = MagicMock() self.assertRaises(Exception, lambda: UnixHost.reconnect(uobject))
def test_unix_reconnect2(self, patch1, patch2, patch3): uobject = MagicMock(spec=UnixHost) uobject.prompt = MagicMock(return_value='%') uobject.host = 'dummy' uobject.user = '******' uobject.password = '******' uobject.connect_mode = 'telnet' uobject._kwargs = MagicMock() uobject.handle = MagicMock() uobject.set_prompt = MagicMock() self.assertTrue(UnixHost.reconnect(uobject))