Author: tomaz
Date: Tue Jun 14 07:50:52 2011
New Revision: 1135398

URL: http://svn.apache.org/viewvc?rev=1135398&view=rev
Log:
Throw an error if an invalid type is passed in to the ScriptDeployment.

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

Modified: libcloud/trunk/libcloud/compute/deployment.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/deployment.py?rev=1135398&r1=1135397&r2=1135398&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/deployment.py (original)
+++ libcloud/trunk/libcloud/compute/deployment.py Tue Jun 14 07:50:52 2011
@@ -76,6 +76,9 @@ class ScriptDeployment(Deployment):
         @type delete: C{bool}
         @keyword delete: Whether to delete the script on completion.
         """
+        if not isinstance(script, basestring):
+            raise TypeError('script argument must be a string')
+
         self.script = script
         self.stdout = None
         self.stderr = None

Modified: libcloud/trunk/test/compute/test_deployment.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_deployment.py?rev=1135398&r1=1135397&r2=1135398&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_deployment.py (original)
+++ libcloud/trunk/test/compute/test_deployment.py Tue Jun 14 07:50:52 2011
@@ -78,5 +78,16 @@ class DeploymentTests(unittest.TestCase)
         self.assertEqual(self.node, sd2.run(node=self.node,
                         client=MockClient(hostname='localhost')))
 
+    def test_script_deployment_argument_types(self):
+        ScriptDeployment(script='foobar')
+        ScriptDeployment(script=unicode('foobar'))
+
+        try:
+            ScriptDeployment(script=[])
+        except TypeError:
+            pass
+        else:
+            self.fail('TypeError was not thrown')
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


Reply via email to