You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/03/16 06:57:41 UTC

svn commit: r1082058 - /incubator/libcloud/trunk/test/compute/test_deployment.py

Author: tomaz
Date: Wed Mar 16 05:57:40 2011
New Revision: 1082058

URL: http://svn.apache.org/viewvc?rev=1082058&view=rev
Log:
Add test for script deployment.

Modified:
    incubator/libcloud/trunk/test/compute/test_deployment.py

Modified: incubator/libcloud/trunk/test/compute/test_deployment.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/compute/test_deployment.py?rev=1082058&r1=1082057&r2=1082058&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/compute/test_deployment.py (original)
+++ incubator/libcloud/trunk/test/compute/test_deployment.py Wed Mar 16 05:57:40 2011
@@ -18,7 +18,7 @@ import sys
 import unittest
 
 from libcloud.compute.deployment import MultiStepDeployment, Deployment
-from libcloud.compute.deployment import SSHKeyDeployment
+from libcloud.compute.deployment import SSHKeyDeployment, ScriptDeployment
 from libcloud.compute.base import Node
 from libcloud.compute.types import NodeState
 from libcloud.compute.ssh import BaseSSHClient
@@ -29,9 +29,20 @@ class MockDeployment(Deployment):
         return node
 
 class MockClient(BaseSSHClient):
-    def put(self, file, contents):
+    def __init__(self, *args, **kwargs):
+        self.stdout = ''
+        self.stderr = ''
+        self.exit_status = 0
+
+    def put(self,  path, contents, chmod=755):
         return contents
 
+    def run(self, name):
+        return self.stdout, self.stderr, self.exit_status
+
+    def delete(self, name):
+        return True
+
 class DeploymentTests(unittest.TestCase):
 
     def setUp(self):
@@ -54,5 +65,11 @@ class DeploymentTests(unittest.TestCase)
         self.assertEqual(self.node, sshd.run(node=self.node,
                         client=MockClient(hostname='localhost')))
 
+    def test_script_deployment(self):
+        sd = ScriptDeployment(script='foobar', delete=True)
+
+        self.assertEqual(self.node, sd.run(node=self.node,
+                        client=MockClient(hostname='localhost')))
+
 if __name__ == '__main__':
     sys.exit(unittest.main())