libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From je...@apache.org
Subject svn commit: r919907 - in /incubator/libcloud/trunk/test: fixtures/ec2/ fixtures/ec2/describe_images.xml fixtures/ec2/describe_instances.xml fixtures/ec2/reboot_instances.xml fixtures/ec2/run_instances.xml fixtures/ec2/terminate_instances.xml test_ec2.py
Date Sun, 07 Mar 2010 01:32:07 GMT
Author: jerry
Date: Sun Mar  7 01:32:06 2010
New Revision: 919907

URL: http://svn.apache.org/viewvc?rev=919907&view=rev
Log:
Commited EC2MockHttp to use FileFixtures

Added:
    incubator/libcloud/trunk/test/fixtures/ec2/
    incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml
    incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml
    incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml
    incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml
    incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml
Modified:
    incubator/libcloud/trunk/test/test_ec2.py

Added: incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml?rev=919907&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml (added)
+++ incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml Sun Mar  7 01:32:06 2010
@@ -0,0 +1,16 @@
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
+  <imagesSet>
+    <item>
+      <imageId>ami-be3adfd7</imageId>
+      <imageLocation>ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml</imageLocation>
+      <imageState>available</imageState>
+      <imageOwnerId>206029621532</imageOwnerId>
+      <isPublic>false</isPublic>
+      <architecture>i386</architecture>
+      <imageType>machine</imageType>
+      <kernelId>aki-4438dd2d</kernelId>
+      <ramdiskId>ari-4538dd2c</ramdiskId>
+    </item>
+  </imagesSet>
+</DescribeImagesResponse>
+

Added: incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml?rev=919907&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml (added)
+++ incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml Sun Mar  7 01:32:06
2010
@@ -0,0 +1,37 @@
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
+  <requestId>56d0fffa-8819-4658-bdd7-548f143a86d2</requestId>
+  <reservationSet>
+    <item>
+      <reservationId>r-07adf66e</reservationId>
+      <ownerId>822272953071</ownerId>
+      <groupSet>
+        <item>
+          <groupId>default</groupId>
+        </item>
+      </groupSet>
+      <instancesSet>
+        <item>
+          <instanceId>i-4382922a</instanceId>
+          <imageId>ami-0d57b264</imageId>
+          <instanceState>
+            <code>0</code>
+            <name>pending</name>
+          </instanceState>
+          <privateDnsName/>
+          <dnsName/>
+          <reason/>
+          <amiLaunchIndex>0</amiLaunchIndex>
+          <productCodes/>
+          <instanceType>m1.small</instanceType>
+          <launchTime>2009-08-07T05:47:04.000Z</launchTime>
+          <placement>
+            <availabilityZone>us-east-1a</availabilityZone>
+          </placement>
+          <monitoring>
+            <state>disabled</state>
+          </monitoring>
+        </item>
+      </instancesSet>
+    </item>
+  </reservationSet>
+</DescribeInstancesResponse>

Added: incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml?rev=919907&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml (added)
+++ incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml Sun Mar  7 01:32:06 2010
@@ -0,0 +1,4 @@
+<RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
+  <requestId>76dabb7a-fb39-4ed1-b5e0-31a4a0fdf5c0</requestId>
+  <return>true</return>
+</RebootInstancesResponse>

Added: incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml?rev=919907&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml (added)
+++ incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml Sun Mar  7 01:32:06 2010
@@ -0,0 +1,31 @@
+<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
+  <reservationId>r-47a5402e</reservationId>
+  <ownerId>AIDADH4IGTRXXKCD</ownerId>
+  <groupSet>
+    <item>
+      <groupId>default</groupId>
+    </item>
+  </groupSet>
+  <instancesSet>
+    <item>
+      <instanceId>i-2ba64342</instanceId>
+      <imageId>ami-be3adfd7</imageId>
+      <instanceState>
+        <code>0</code>
+        <name>pending</name>
+      </instanceState>
+      <privateDnsName></privateDnsName>
+      <dnsName></dnsName>
+      <keyName>example-key-name</keyName>
+      <amiLaunchIndex>0</amiLaunchIndex>
+      <instanceType>m1.small</instanceType>
+      <launchTime>2007-08-07T11:51:50.000Z</launchTime>
+      <placement>
+        <availabilityZone>us-east-1b</availabilityZone>
+      </placement>
+      <monitoring>
+        <enabled>true</enabled>
+      </monitoring>
+    </item>
+  </instancesSet>
+</RunInstancesResponse>

Added: incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml?rev=919907&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml (added)
+++ incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml Sun Mar  7 01:32:06
2010
@@ -0,0 +1,16 @@
+<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
+  <requestId>fa63083d-e0f7-4933-b31a-f266643bdee8</requestId>
+  <instancesSet>
+    <item>
+      <instanceId>i-4382922a</instanceId>
+      <shutdownState>
+        <code>32</code>
+        <name>shutting-down</name>
+      </shutdownState>
+      <previousState>
+        <code>16</code>
+        <name>running</name>
+      </previousState>
+    </item>
+  </instancesSet>
+</TerminateInstancesResponse>

Modified: incubator/libcloud/trunk/test/test_ec2.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_ec2.py?rev=919907&r1=919906&r2=919907&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_ec2.py (original)
+++ incubator/libcloud/trunk/test/test_ec2.py Sun Mar  7 01:32:06 2010
@@ -19,6 +19,7 @@
 from libcloud.base import Node, NodeImage, NodeSize
 
 from test import MockHttp, TestCaseMixin
+from test.file_fixtures import FileFixtures
 
 import httplib
 
@@ -69,122 +70,27 @@
         self.assertEqual(image.id, 'ami-be3adfd7')
 
 class EC2MockHttp(MockHttp):
+
+    fixtures = FileFixtures('ec2')
+
     def _DescribeInstances(self, method, url, body, headers):
-        body = """<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
-    <requestId>56d0fffa-8819-4658-bdd7-548f143a86d2</requestId>
-    <reservationSet>
-        <item>
-            <reservationId>r-07adf66e</reservationId>
-            <ownerId>822272953071</ownerId>
-            <groupSet>
-                <item>
-                    <groupId>default</groupId>
-                </item>
-            </groupSet>
-            <instancesSet>
-                <item>
-                    <instanceId>i-4382922a</instanceId>
-                    <imageId>ami-0d57b264</imageId>
-                    <instanceState>
-                        <code>0</code>
-                        <name>pending</name>
-                    </instanceState>
-                    <privateDnsName/>
-                    <dnsName/>
-                    <reason/>
-                    <amiLaunchIndex>0</amiLaunchIndex>
-                    <productCodes/>
-                    <instanceType>m1.small</instanceType>
-                    <launchTime>2009-08-07T05:47:04.000Z</launchTime>
-                    <placement>
-                        <availabilityZone>us-east-1a</availabilityZone>
-                    </placement>
-                    <monitoring>
-                        <state>disabled</state>
-                    </monitoring>
-                </item>
-            </instancesSet>
-        </item>
-    </reservationSet>
-</DescribeInstancesResponse>"""
+        body = self.fixtures.load('describe_instances.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _RebootInstances(self, method, url, body, headers):
-        body = """<RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
-    <requestId>76dabb7a-fb39-4ed1-b5e0-31a4a0fdf5c0</requestId>
-    <return>true</return>
-</RebootInstancesResponse>"""
+        body = self.fixtures.load('reboot_instances.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _DescribeImages(self, method, url, body, headers):
-        body = """<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
-                  <imagesSet>
-                    <item>
-                      <imageId>ami-be3adfd7</imageId>
-                      <imageLocation>ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml</imageLocation>
-                      <imageState>available</imageState>
-                      <imageOwnerId>206029621532</imageOwnerId>
-                      <isPublic>false</isPublic>
-                      <architecture>i386</architecture>
-                      <imageType>machine</imageType>
-                      <kernelId>aki-4438dd2d</kernelId>
-                      <ramdiskId>ari-4538dd2c</ramdiskId>
-                    </item>
-                  </imagesSet>
-                </DescribeImagesResponse>"""
+        body = self.fixtures.load('describe_images.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _RunInstances(self, method, url, body, headers):
-        body = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
-                      <reservationId>r-47a5402e</reservationId>
-                      <ownerId>AIDADH4IGTRXXKCD</ownerId>
-                      <groupSet>
-                        <item>
-                          <groupId>default</groupId>
-                        </item>
-                      </groupSet>
-                      <instancesSet>
-                        <item>
-                          <instanceId>i-2ba64342</instanceId>
-                          <imageId>ami-be3adfd7</imageId>
-                          <instanceState>
-                            <code>0</code>
-                            <name>pending</name>
-                          </instanceState>
-                          <privateDnsName></privateDnsName>
-                          <dnsName></dnsName>
-                          <keyName>example-key-name</keyName>
-                          <amiLaunchIndex>0</amiLaunchIndex>
-                          <instanceType>m1.small</instanceType>
-                          <launchTime>2007-08-07T11:51:50.000Z</launchTime>
-                          <placement>
-                            <availabilityZone>us-east-1b</availabilityZone>
-                          </placement>
-                          <monitoring>
-                            <enabled>true</enabled>
-                          </monitoring>
-                        </item>
-                      </instancesSet>
-                    </RunInstancesResponse>"""
+        body = self.fixtures.load('run_instances.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _TerminateInstances(self, method, url, body, headers):
-        body = """<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
-    <requestId>fa63083d-e0f7-4933-b31a-f266643bdee8</requestId>
-    <instancesSet>
-        <item>
-            <instanceId>i-4382922a</instanceId>
-            <shutdownState>
-                <code>32</code>
-                <name>shutting-down</name>
-            </shutdownState>
-            <previousState>
-                <code>16</code>
-                <name>running</name>
-            </previousState>
-        </item>
-    </instancesSet>
-</TerminateInstancesResponse>"""
+        body = self.fixtures.load('terminate_instances.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
 if __name__ == '__main__':



Mime
View raw message