libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From or...@apache.org
Subject svn commit: r924571 - in /incubator/libcloud/trunk/test: fixtures/softlayer/ fixtures/softlayer/v3_SoftLayer_Account_getVirtualGuests.xml secrets.py-dist test_softlayer.py
Date Thu, 18 Mar 2010 00:37:49 GMT
Author: oremj
Date: Thu Mar 18 00:37:49 2010
New Revision: 924571

URL: http://svn.apache.org/viewvc?rev=924571&view=rev
Log:
Softlayer testing.

Added:
    incubator/libcloud/trunk/test/fixtures/softlayer/
    incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Account_getVirtualGuests.xml
    incubator/libcloud/trunk/test/test_softlayer.py
Modified:
    incubator/libcloud/trunk/test/secrets.py-dist

Added: incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Account_getVirtualGuests.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Account_getVirtualGuests.xml?rev=924571&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Account_getVirtualGuests.xml
(added)
+++ incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Account_getVirtualGuests.xml
Thu Mar 18 00:37:49 2010
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<params>
+<param>
+ <value>
+  <array>
+   <data>
+    <value>
+     <struct>
+      <member>
+       <name>privateNetworkOnlyFlag</name>
+       <value>
+        <boolean>0</boolean>
+       </value>
+      </member>
+      <member>
+       <name>id</name>
+       <value>
+        <int>0</int>
+       </value>
+      </member>
+      <member>
+       <name>accountId</name>
+       <value>
+        <int>0</int>
+       </value>
+      </member>
+      <member>
+       <name>statusId</name>
+       <value>
+        <int>1001</int>
+       </value>
+      </member>
+      <member>
+       <name>uuid</name>
+       <value>
+        <string>ea11b502-8e2d-d8d0-1111-611111111111</string>
+       </value>
+      </member>
+      <member>
+       <name>hostname</name>
+       <value>
+        <string>test</string>
+       </value>
+      </member>
+      <member>
+       <name>domain</name>
+       <value>
+        <string>libcloud.org</string>
+       </value>
+      </member>
+      <member>
+       <name>maxCpu</name>
+       <value>
+        <int>2</int>
+       </value>
+      </member>
+      <member>
+       <name>maxCpuUnits</name>
+       <value>
+        <string>CORE</string>
+       </value>
+      </member>
+      <member>
+       <name>maxMemory</name>
+       <value>
+        <int>2048</int>
+       </value>
+      </member>
+      <member>
+       <name>startCpus</name>
+       <value>
+        <int>2</int>
+       </value>
+      </member>
+      <member>
+       <name>createDate</name>
+       <value>
+        <string>2009-09-04T14:49:45-05:00</string>
+       </value>
+      </member>
+      <member>
+       <name>modifyDate</name>
+       <value>
+        <string>2010-03-17T19:23:59-05:00</string>
+       </value>
+      </member>
+      <member>
+       <name>metricPollDate</name>
+       <value>
+        <string>2010-03-17T19:23:00-05:00</string>
+       </value>
+      </member>
+      <member>
+       <name>dedicatedAccountHostOnlyFlag</name>
+       <value>
+        <boolean>0</boolean>
+       </value>
+      </member>
+      <member>
+       <name>primaryIpAddress</name>
+       <value>
+        <string>62.233.333.333</string>
+       </value>
+      </member>
+      <member>
+       <name>primaryBackendIpAddress</name>
+       <value>
+        <string>10.20.172.130</string>
+       </value>
+      </member>
+     </struct>
+    </value>
+   </data>
+  </array>
+ </value>
+</param>
+</params>

Modified: incubator/libcloud/trunk/test/secrets.py-dist
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/secrets.py-dist?rev=924571&r1=924570&r2=924571&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/secrets.py-dist (original)
+++ incubator/libcloud/trunk/test/secrets.py-dist Thu Mar 18 00:37:49 2010
@@ -39,5 +39,8 @@ HOSTINGCOM_SECRET=''
 TERREMARK_USER=''
 TERREMARK_SECRET=''
 
+SOFTLAYER_USER=''
+SOFTLAYER_APIKEY=''
+
 VOXEL_KEY=''
 VOXEL_SECRET=''

Added: incubator/libcloud/trunk/test/test_softlayer.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_softlayer.py?rev=924571&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/test_softlayer.py (added)
+++ incubator/libcloud/trunk/test/test_softlayer.py Thu Mar 18 00:37:49 2010
@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# libcloud.org licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import httplib
+import unittest
+from xml.etree import ElementTree as ET
+import xmlrpclib
+
+from libcloud.drivers.softlayer import SoftLayerProxy, SoftLayerNodeDriver as SoftLayer
+from libcloud.base import Node, NodeImage, NodeSize
+
+from test import MockHttp, TestCaseMixin
+from test.file_fixtures import FileFixtures
+
+from secrets import SOFTLAYER_USER, SOFTLAYER_APIKEY
+
+class MockSoftLayerTransport(xmlrpclib.Transport):
+    
+    def request(self, host, handler, request_body, verbose=0):
+        self.verbose = 0
+        method = ET.XML(request_body).find('methodName').text
+        mock = SoftLayerMockHttp(host, 80) 
+        mock.request('POST', "%s/%s" % (handler, method))
+        resp = mock.getresponse()
+
+        return self._parse_response(resp.body, None)
+
+class SoftLayerTests(unittest.TestCase):
+
+    def setUp(self):
+        SoftLayer.connectionCls.proxyCls.transportCls = MockSoftLayerTransport
+        self.driver = SoftLayer(SOFTLAYER_USER, SOFTLAYER_APIKEY)
+
+    def test_list_nodes(self):
+        node = self.driver.list_nodes()[0]
+        self.assertEqual(node.name, 'test')
+
+class SoftLayerMockHttp(MockHttp):
+    fixtures = FileFixtures('softlayer')
+
+    def _xmlrpc_v3_SoftLayer_Account_getVirtualGuests(self, method, url, body, headers):
+        body = self.fixtures.load('v3_SoftLayer_Account_getVirtualGuests.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+if __name__ == '__main__':
+    sys.exit(unittest.main())



Mime
View raw message