Update affected tests and add some news ones.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9dca0088 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9dca0088 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9dca0088 Branch: refs/heads/trunk Commit: 9dca00889c8601fd3181466e2bd069dcfdb70272 Parents: 195efc9 Author: Tomaz Muraus <[email protected]> Authored: Wed Jan 8 23:59:49 2014 +0100 Committer: Tomaz Muraus <[email protected]> Committed: Thu Jan 9 00:06:19 2014 +0100 ---------------------------------------------------------------------- libcloud/test/compute/test_ssh_client.py | 50 +++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/9dca0088/libcloud/test/compute/test_ssh_client.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_ssh_client.py b/libcloud/test/compute/test_ssh_client.py index 338ab66..eb674f1 100644 --- a/libcloud/test/compute/test_ssh_client.py +++ b/libcloud/test/compute/test_ssh_client.py @@ -52,12 +52,6 @@ class ParamikoSSHClientTests(unittest.TestCase): @patch('paramiko.SSHClient', Mock) def test_create_with_password(self): - """ - Initialize object with password. - - Just to have better coverage, initialize the object - with the 'password' value instead of the 'key'. - """ conn_params = {'hostname': 'dummy.host.org', 'username': 'ubuntu', 'password': 'ubuntu'} @@ -66,9 +60,45 @@ class ParamikoSSHClientTests(unittest.TestCase): expected_conn = {'username': 'ubuntu', 'password': 'ubuntu', - 'allow_agent': False, + 'allow_agent': True, 'hostname': 'dummy.host.org', - 'look_for_keys': False, + 'look_for_keys': True, + 'port': 22} + mock.client.connect.assert_called_once_with(**expected_conn) + self.assertLogMsg('Connecting to server') + + @patch('paramiko.SSHClient', Mock) + def test_create_with_key(self): + conn_params = {'hostname': 'dummy.host.org', + 'username': 'ubuntu', + 'key': 'id_rsa'} + mock = ParamikoSSHClient(**conn_params) + mock.connect() + + expected_conn = {'username': 'ubuntu', + 'allow_agent': True, + 'hostname': 'dummy.host.org', + 'look_for_keys': True, + 'key_filename': 'id_rsa', + 'port': 22} + mock.client.connect.assert_called_once_with(**expected_conn) + self.assertLogMsg('Connecting to server') + + @patch('paramiko.SSHClient', Mock) + def test_create_with_password_and_key(self): + conn_params = {'hostname': 'dummy.host.org', + 'username': 'ubuntu', + 'password': 'ubuntu', + 'key': 'id_rsa'} + mock = ParamikoSSHClient(**conn_params) + mock.connect() + + expected_conn = {'username': 'ubuntu', + 'password': 'ubuntu', + 'allow_agent': True, + 'hostname': 'dummy.host.org', + 'look_for_keys': True, + 'key_filename': 'id_rsa', 'port': 22} mock.client.connect.assert_called_once_with(**expected_conn) self.assertLogMsg('Connecting to server') @@ -106,9 +136,9 @@ class ParamikoSSHClientTests(unittest.TestCase): mock_cli = mock.client # The actual mocked object: SSHClient expected_conn = {'username': 'ubuntu', 'key_filename': '~/.ssh/ubuntu_ssh', - 'allow_agent': False, + 'allow_agent': True, 'hostname': 'dummy.host.org', - 'look_for_keys': False, + 'look_for_keys': True, 'timeout': '600', 'port': 8822} mock_cli.connect.assert_called_once_with(**expected_conn)
