def test_put(self, mock_scp_client_type): auto_connect_ssh = AutoConnectSSH('user1', 'host1') auto_connect_ssh._client = mock.Mock() auto_connect_ssh.put('a', 'z') with mock_scp_client_type() as mock_scp_client: self.assertEqual(mock_scp_client.put.call_count, 1)
def test_put_file(self): auto_connect_ssh = AutoConnectSSH('user1', 'host1') auto_connect_ssh._client = mock.Mock() auto_connect_ssh._put_file_sftp = mock_put_sftp = mock.Mock() auto_connect_ssh.put_file('a', 'b') self.assertEqual(mock_put_sftp.call_count, 1)
def test_put_file(self): auto_connect_ssh = AutoConnectSSH('user1', 'host1') auto_connect_ssh._client = mock.Mock() auto_connect_ssh._put_file_sftp = mock_put_sftp = mock.Mock() auto_connect_ssh.put_file('a', 'b') mock_put_sftp.assert_called_once()
def test_get(self, mock_scp_client_type): auto_connect_ssh = AutoConnectSSH('user1', 'host1') auto_connect_ssh._client = mock.Mock() auto_connect_ssh.get('a', 'z') with mock_scp_client_type() as mock_scp_client: mock_scp_client.get.assert_called_once()
def test_execute_command_error(self): auto_connect_ssh = AutoConnectSSH('user1', 'host1') auto_connect_ssh._client = mock.Mock() auto_connect_ssh.run = mock.Mock(side_effect=self._mock_run) self.assertRaises(exceptions.SSHError, auto_connect_ssh.execute, 'ls', raise_on_error=True) exit_code, _, _ = auto_connect_ssh.execute('ls') self.assertNotEqual(exit_code, 0)
def test_execute(self): auto_connect_ssh = AutoConnectSSH('user1', 'host1') auto_connect_ssh._client = mock.Mock() auto_connect_ssh.run = mock.Mock(return_value=0) exit_code, _, _ = auto_connect_ssh.execute('') self.assertEqual(exit_code, 0)
def test_drop_connection(self): auto_connect_ssh = AutoConnectSSH('user1', 'host1') self.assertFalse(auto_connect_ssh._client) auto_connect_ssh._client = True auto_connect_ssh.drop_connection() self.assertFalse(auto_connect_ssh._client)