def test_file_exists_no_file(self, mock_ssh_client): sftp_mock = mock.Mock() sftp_mock.stat.side_effect = IOError() transport_mock = mock.Mock() transport_mock.open_sftp_client.return_value = sftp_mock mock_ssh_client.get_transport.return_value = transport_mock a = ACSClient(mock_ssh_client) a.connect('somehost', 'someusername') actual = a.file_exists('somefile') self.assertEqual(actual, False)
def test_file_exists_positive(self, mock_ssh_client): sftp_mock = mock.Mock() sftp_mock.stat.side_efect = 'filexists' transport_mock = mock.Mock() transport_mock.open_sftp_client.return_value = sftp_mock mock_ssh_client.get_transport.return_value = transport_mock a = ACSClient(mock_ssh_client) a.connect('somehost', 'someusername') actual = a.file_exists('somefile') self.assertEqual(actual, True)