# Path: IM/SSHRetry.py
# class SSHRetry(SSH):
#     TRIES = 5
#     DELAY = 3
#     BACKOFF = 2
#     def execute(self, command, timeout=None):
#     def sftp_get(self, src, dest):
#     def sftp_get_files(self, src, dest):
#     def sftp_put_files(self, files):
#     def sftp_put(self, src, dest):
#     def sftp_put_dir(self, src, dest):
#     def sftp_get_dir(self, src, dest):
#     def sftp_put_content(self, content, dest):
#     def sftp_mkdir(self, directory, mode=0o777):
#     def sftp_list(self, directory):
#     def sftp_list_attr(self, directory):
#     def getcwd(self):
#     def sftp_remove(self, path):
#     def sftp_chmod(self, path, mode):


import unittest
import os
from IM.SSHRetry import SSHRetry, SSH
from mock import patch, MagicMock
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




def read_file_as_string(file_name):
    tests_path = os.path.dirname(os.path.abspath(__file__))
    abs_file_path = os.path.join(tests_path, file_name)
    return open(abs_file_path, 'r').read()


class TestSSH(unittest.TestCase):
    """
    Class to test the SSH class
    """

    def test_str(self):
        ssh = SSH("host", "user", "passwd", read_file_as_string("../files/privatekey.pem"))
        expected_res = ("SSH: host: host, port: 22, user: user, password: passwd, "
                        "private_key: %s" % read_file_as_string("../files/privatekey.pem"))
        self.assertEqual(str(ssh), expected_res)

    @patch('paramiko.SSHClient')
    def test_test_connectivity(self, ssh_client):
        ssh = SSHRetry("host", "user", "passwd", read_file_as_string("../files/privatekey.pem"))
        success = ssh.test_connectivity(5)
        self.assertTrue(success)

    @patch('paramiko.SSHClient')
    def test_test_connectivity_proxy(self, ssh_client):

# Path: IM/SSHRetry.py
# class SSHRetry(SSH):
#     TRIES = 5
#     DELAY = 3
#     BACKOFF = 2
#     def execute(self, command, timeout=None):
#     def sftp_get(self, src, dest):
#     def sftp_get_files(self, src, dest):
#     def sftp_put_files(self, files):
#     def sftp_put(self, src, dest):
#     def sftp_put_dir(self, src, dest):
#     def sftp_get_dir(self, src, dest):
#     def sftp_put_content(self, content, dest):
#     def sftp_mkdir(self, directory, mode=0o777):
#     def sftp_list(self, directory):
#     def sftp_list_attr(self, directory):
#     def getcwd(self):
#     def sftp_remove(self, path):
#     def sftp_chmod(self, path, mode):


# Path: test/unit/SSH.py
import unittest
import os
from IM.SSHRetry import SSHRetry, SSH
from mock import patch, MagicMock

# along with this program.  If not, see <http://www.gnu.org/licenses/>.




def read_file_as_string(file_name):
    tests_path = os.path.dirname(os.path.abspath(__file__))
    abs_file_path = os.path.join(tests_path, file_name)
    return open(abs_file_path, 'r').read()


class TestSSH(unittest.TestCase):
    """
    Class to test the SSH class
    """

    def test_str(self):
        ssh = SSH("host", "user", "passwd", read_file_as_string("../files/privatekey.pem"))
        expected_res = ("SSH: host: host, port: 22, user: user, password: passwd, "
                        "private_key: %s" % read_file_as_string("../files/privatekey.pem"))
        self.assertEqual(str(ssh), expected_res)

    @patch('paramiko.SSHClient')
    def test_test_connectivity(self, ssh_client):
        ssh = SSHRetry("host", "user", "passwd", read_file_as_string("../files/privatekey.pem"))
        success = ssh.test_connectivity(5)
        self.assertTrue(success)

    @patch('paramiko.SSHClient')
    def test_test_connectivity_proxy(self, ssh_client):

        proxy = SSH("proxy", "userp", "passwdp")