Author: tomaz
Date: Sun Mar 10 05:05:55 2013
New Revision: 1454788
URL: http://svn.apache.org/r1454788
Log:
Fix a regression in ParamikoSSHClient.run method.
Change SSHClient interface a bit and make "put" method return a full path to the
location where a file has been saved.
Remove old invalid test and add a new one.
Part of LIBCLOUD-278.
Modified:
libcloud/trunk/libcloud/test/compute/test_deployment.py
libcloud/trunk/libcloud/test/compute/test_ssh_client.py
Modified: libcloud/trunk/libcloud/test/compute/test_deployment.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_deployment.py?rev=1454788&r1=1454787&r2=1454788&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_deployment.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_deployment.py Sun Mar 10 05:05:55
2013
@@ -111,6 +111,26 @@ class DeploymentTests(unittest.TestCase)
self.assertEqual(self.node, sd2.run(node=self.node,
client=MockClient(hostname='localhost')))
+ def test_script_deployment_relative_path(self):
+ client = Mock()
+ client.put.return_value = '/home/ubuntu/relative.sh'
+ client.run.return_value = ('', '', 0)
+
+ sd = ScriptDeployment(script='echo "foo"', name='relative.sh')
+ sd.run(self.node, client)
+
+ client.run.assert_called_once_with('/home/ubuntu/relative.sh')
+
+ def test_script_deployment_absolute_path(self):
+ client = Mock()
+ client.put.return_value = '/home/ubuntu/relative.sh'
+ client.run.return_value = ('', '', 0)
+
+ sd = ScriptDeployment(script='echo "foo"', name='/root/relative.sh')
+ sd.run(self.node, client)
+
+ client.run.assert_called_once_with('/root/relative.sh')
+
def test_script_deployment_and_sshkey_deployment_argument_types(self):
class FileObject(object):
def __init__(self, name):
Modified: libcloud/trunk/libcloud/test/compute/test_ssh_client.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_ssh_client.py?rev=1454788&r1=1454787&r2=1454788&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_ssh_client.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_ssh_client.py Sun Mar 10 05:05:55
2013
@@ -117,40 +117,6 @@ class ParamikoSSHClientTests(unittest.Te
mock.close()
- def _disabled_test_run_script_with_relative_path(self):
- """
- Execute script with relative path.
- """
- mock = self.ssh_cli
-
- # Define behaviour then ask for 'current directory'
- mock.client.open_sftp().getcwd.return_value = '/home/ubuntu/'
-
- # Script without full path
- sd = 'random_script.sh'
-
- # Without assertions because they are the same than the previous
- # 'test_basic_usage' method
- mock.connect()
-
- mock_cli = mock.client # The actual mocked object: SSHClient
-
- mock.put(sd, chmod=600)
- # Make assertions over 'put' method
- mock_cli.open_sftp().file.assert_called_once_with('random_script.sh',
- mode='w')
- mock_cli.open_sftp().file().chmod.assert_called_once_with(600)
-
- mock.run(sd)
- # Make assertions over the 'run' method
- mock_cli.open_sftp().chdir.assert_called_with(".")
- mock_cli.open_sftp().getcwd.assert_called_once()
- full_sd = '/home/ubuntu/random_script.sh'
- mock_cli.get_transport().open_session().exec_command \
- .assert_called_once_with(full_sd)
-
- mock.close()
-
def test_delete_script(self):
"""
Provide a basic test with 'delete' action.