You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by pq...@apache.org on 2010/05/05 02:13:51 UTC
svn commit: r941117 - in /incubator/libcloud/trunk/test: __init__.py
test_base.py test_ec2.py test_ecp.py test_ibm.py test_linode.py
test_opennebula.py test_rackspace.py test_rimuhosting.py test_softlayer.py
test_vcloud.py test_vpsnet.py
Author: pquerna
Date: Wed May 5 00:13:51 2010
New Revision: 941117
URL: http://svn.apache.org/viewvc?rev=941117&view=rev
Log:
Style cleanups on tests; No functional changes.
Modified:
incubator/libcloud/trunk/test/__init__.py
incubator/libcloud/trunk/test/test_base.py
incubator/libcloud/trunk/test/test_ec2.py
incubator/libcloud/trunk/test/test_ecp.py
incubator/libcloud/trunk/test/test_ibm.py
incubator/libcloud/trunk/test/test_linode.py
incubator/libcloud/trunk/test/test_opennebula.py
incubator/libcloud/trunk/test/test_rackspace.py
incubator/libcloud/trunk/test/test_rimuhosting.py
incubator/libcloud/trunk/test/test_softlayer.py
incubator/libcloud/trunk/test/test_vcloud.py
incubator/libcloud/trunk/test/test_vpsnet.py
Modified: incubator/libcloud/trunk/test/__init__.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/__init__.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/__init__.py (original)
+++ incubator/libcloud/trunk/test/__init__.py Wed May 5 00:13:51 2010
@@ -55,10 +55,10 @@ class MockResponse(object):
def read(self, *args, **kwargs):
return self.body.read(*args, **kwargs)
-
+
def getheader(self, name, *args, **kwargs):
return self.headers.get(name, *args, **kwargs)
-
+
def getheaders(self):
return self.headers.items()
@@ -68,12 +68,12 @@ class MockResponse(object):
class MockHttp(object):
"""
- A mock HTTP client/server suitable for testing purposes. This replaces
+ A mock HTTP client/server suitable for testing purposes. This replaces
`HTTPConnection` by implementing its API and returning a mock response.
Define methods by request path, replacing slashes (/) with underscores (_).
Each of these mock methods should return a tuple of:
-
+
(int status, str body, dict headers, str reason)
>>> mock = MockHttp('localhost', 8080)
@@ -101,7 +101,7 @@ class MockHttp(object):
port = None
response = None
- type = None
+ type = None
use_param = None # will use this param to namespace the request function
def __init__(self, host, port, *args, **kwargs):
@@ -117,7 +117,7 @@ class MockHttp(object):
path = path[:-1]
meth_name = path.replace('/','_').replace('.', '_').replace('-','_')
if self.type:
- meth_name = '%s_%s' % (meth_name, self.type)
+ meth_name = '%s_%s' % (meth_name, self.type)
if self.use_param:
param = qs[self.use_param][0].replace('.', '_')
meth_name = '%s_%s' % (meth_name, param)
@@ -205,4 +205,3 @@ class TestCaseMixin(object):
if __name__ == "__main__":
import doctest
doctest.testmod()
-
Modified: incubator/libcloud/trunk/test/test_base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_base.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_base.py (original)
+++ incubator/libcloud/trunk/test/test_base.py Wed May 5 00:13:51 2010
@@ -29,12 +29,12 @@ from libcloud.base import ConnectionKey,
from test import MockResponse
class FakeDriver(object):
- type = 0
+ type = 0
class BaseTests(unittest.TestCase):
def test_base_node(self):
- node = Node(id=0, name=0, state=0, public_ip=0, private_ip=0,
+ node = Node(id=0, name=0, state=0, public_ip=0, private_ip=0,
driver=FakeDriver())
verifyObject(INode, node)
@@ -58,7 +58,7 @@ class BaseTests(unittest.TestCase):
def test_base_connection_key(self):
conn = ConnectionKey('foo')
verifyObject(IConnectionKey, conn)
-
+
def test_base_connection_userkey(self):
conn = ConnectionUserAndKey('foo', 'bar')
verifyObject(IConnectionUserAndKey, conn)
Modified: incubator/libcloud/trunk/test/test_ec2.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_ec2.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_ec2.py (original)
+++ incubator/libcloud/trunk/test/test_ec2.py Wed May 5 00:13:51 2010
@@ -33,7 +33,7 @@ class EC2Tests(unittest.TestCase, TestCa
self.driver = EC2NodeDriver(EC2_ACCESS_ID, EC2_SECRET)
def test_create_node(self):
- image = NodeImage(id='ami-be3adfd7',
+ image = NodeImage(id='ami-be3adfd7',
name='ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml',
driver=self.driver)
size = NodeSize('m1.small', 'Small Instance', None, None, None, None, driver=self.driver)
Modified: incubator/libcloud/trunk/test/test_ecp.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_ecp.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_ecp.py (original)
+++ incubator/libcloud/trunk/test/test_ecp.py Wed May 5 00:13:51 2010
@@ -40,7 +40,7 @@ class ECPTests(unittest.TestCase, TestCa
self.assertEqual(node.name, 'dummy-1')
self.assertEqual(node.public_ip[0], "42.78.124.75")
self.assertEqual(node.state, NodeState.RUNNING)
-
+
def test_list_sizes(self):
sizes = self.driver.list_sizes()
@@ -69,7 +69,7 @@ class ECPTests(unittest.TestCase, TestCa
# Raises exception on failure
node = self.driver.list_nodes()[0]
self.driver.destroy_node(node)
-
+
def test_create_node(self):
# Raises exception on failure
size = self.driver.list_sizes()[0]
@@ -77,7 +77,7 @@ class ECPTests(unittest.TestCase, TestCa
node = self.driver.create_node(name="api.ivan.net.nz", image=image, size=size)
self.assertEqual(node.name, "api.ivan.net.nz")
self.assertEqual(node.id, "1234")
-
+
class ECPMockHttp(MockHttp):
fixtures = FileFixtures('ecp')
@@ -87,7 +87,7 @@ class ECPMockHttp(MockHttp):
headers['set-cookie'] = 'vcloud-token=testtoken'
body = 'Anything'
return (httplib.OK, body, headers, httplib.responses[httplib.OK])
-
+
def _rest_hosting_vm_1(self, method, url, body, headers):
if method == 'GET':
body = self.fixtures.load('vm_1_get.json')
@@ -99,24 +99,24 @@ class ECPMockHttp(MockHttp):
if body.find('start',0):
body = self.fixtures.load('vm_1_action_start.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _rest_hosting_vm(self, method, url, body, headers):
if method == 'PUT':
body = self.fixtures.load('vm_put.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _rest_hosting_vm_list(self, method, url, body, headers):
body = self.fixtures.load('vm_list.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _rest_hosting_htemplate_list(self, method, url, body, headers):
body = self.fixtures.load('htemplate_list.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _rest_hosting_network_list(self, method, url, body, headers):
body = self.fixtures.load('network_list.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _rest_hosting_ptemplate_list(self, method, url, body, headers):
body = self.fixtures.load('ptemplate_list.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
Modified: incubator/libcloud/trunk/test/test_ibm.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_ibm.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_ibm.py (original)
+++ incubator/libcloud/trunk/test/test_ibm.py Wed May 5 00:13:51 2010
@@ -26,23 +26,23 @@ class IBMTests(unittest.TestCase, TestCa
"""
Tests the IBM Developer Cloud driver.
"""
-
+
def setUp(self):
IBM.connectionCls.conn_classes = (None, IBMMockHttp)
IBMMockHttp.type = None
self.driver = IBM(IBM_USER, IBM_SECRET)
-
+
def test_auth(self):
IBMMockHttp.type = 'UNAUTHORIZED'
-
+
try:
self.driver.list_nodes()
except InvalidCredsException, e:
self.assertTrue(isinstance(e, InvalidCredsException))
self.assertEquals(e.value, '401: Unauthorized')
- else:
+ else:
self.fail('test should have thrown')
-
+
def test_list_nodes(self):
ret = self.driver.list_nodes()
self.assertEquals(len(ret), 3)
@@ -53,7 +53,7 @@ class IBMTests(unittest.TestCase, TestCa
self.assertEquals(ret[1].public_ip, None) # Node is non-active (no IP)
self.assertEquals(ret[1].private_ip, None)
self.assertEquals(ret[1].id, '28193')
-
+
def test_list_sizes(self):
ret = self.driver.list_sizes()
self.assertEquals(len(ret), 3) # 3 instance configurations supported
@@ -62,20 +62,20 @@ class IBMTests(unittest.TestCase, TestCa
self.assertEquals(ret[2].id, 'LARGE')
self.assertEquals(ret[0].name, 'SMALL')
self.assertEquals(ret[0].disk, None)
-
+
def test_list_images(self):
ret = self.driver.list_images()
self.assertEqual(len(ret), 21)
self.assertEqual(ret[10].name, "Rational Asset Manager 7.2.0.1")
self.assertEqual(ret[9].id, '10002573')
-
+
def test_list_locations(self):
ret = self.driver.list_locations()
self.assertEquals(len(ret), 1)
self.assertEquals(ret[0].id, '1')
self.assertEquals(ret[0].name, 'US North East: Poughkeepsie, NY')
self.assertEquals(ret[0].country, 'US')
-
+
def test_create_node(self):
# Test creation of node
IBMMockHttp.type = 'CREATE'
@@ -93,7 +93,7 @@ class IBMTests(unittest.TestCase, TestCa
'report_user_password': 'myPassword3'})
self.assertTrue(isinstance(ret, Node))
self.assertEquals(ret.name, 'RationalInsight4')
-
+
# Test creation attempt with invalid location
IBMMockHttp.type = 'CREATE_INVALID'
location = NodeLocation('3', 'DOESNOTEXIST', 'US', driver=self.driver)
@@ -111,8 +111,8 @@ class IBMTests(unittest.TestCase, TestCa
self.assertEquals(e.args[0], 'Error 412: No DataCenter with id: 3')
else:
self.fail('test should have thrown')
-
- def test_destroy_node(self):
+
+ def test_destroy_node(self):
# Delete existant node
nodes = self.driver.list_nodes() # retrieves 3 nodes
self.assertEquals(len(nodes), 3)
@@ -120,7 +120,7 @@ class IBMTests(unittest.TestCase, TestCa
toDelete = nodes[1]
ret = self.driver.destroy_node(toDelete)
self.assertTrue(ret)
-
+
# Delete non-existant node
IBMMockHttp.type = 'DELETED'
nodes = self.driver.list_nodes() # retrieves 2 nodes
@@ -131,16 +131,16 @@ class IBMTests(unittest.TestCase, TestCa
self.assertEquals(e.args[0], 'Error 404: Invalid Instance ID 28193')
else:
self.fail('test should have thrown')
-
+
def test_reboot_node(self):
nodes = self.driver.list_nodes()
IBMMockHttp.type = 'REBOOT'
-
+
# Reboot active node
self.assertEquals(len(nodes), 3)
ret = self.driver.reboot_node(nodes[0])
self.assertTrue(ret)
-
+
# Reboot inactive node
try:
ret = self.driver.reboot_node(nodes[1])
@@ -148,50 +148,50 @@ class IBMTests(unittest.TestCase, TestCa
self.assertEquals(e.args[0], 'Error 412: Instance must be in the Active state')
else:
self.fail('test should have thrown')
-
+
class IBMMockHttp(MockHttp):
fixtures = FileFixtures('ibm')
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances(self, method, url, body, headers):
body = self.fixtures.load('instances.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_DELETED(self, method, url, body, headers):
body = self.fixtures.load('instances_deleted.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_UNAUTHORIZED(self, method, url, body, headers):
return (httplib.UNAUTHORIZED, body, {}, httplib.responses[httplib.UNAUTHORIZED])
-
+
def _cloud_enterprise_beta_api_rest_20090403_images(self, method, url, body, headers):
body = self.fixtures.load('images.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_locations(self, method, url, body, headers):
body = self.fixtures.load('locations.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_26557_REBOOT(self, method, url, body, headers):
body = self.fixtures.load('reboot_active.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_28193_REBOOT(self, method, url, body, headers):
return (412, 'Error 412: Instance must be in the Active state', {}, 'Precondition Failed')
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_28193_DELETE(self, method, url, body, headers):
body = self.fixtures.load('delete.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_28193_DELETED(self, method, url, body, headers):
return (404, 'Error 404: Invalid Instance ID 28193', {}, 'Precondition Failed')
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_CREATE(self, method, url, body, headers):
body = self.fixtures.load('create.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _cloud_enterprise_beta_api_rest_20090403_instances_CREATE_INVALID(self, method, url, body, headers):
return (412, 'Error 412: No DataCenter with id: 3', {}, 'Precondition Failed')
-
+
# This is only to accomodate the response tests built into test\__init__.py
def _cloud_enterprise_beta_api_rest_20090403_instances_26557(self, method, url, body, headers):
if method == 'DELETE':
@@ -199,6 +199,6 @@ class IBMMockHttp(MockHttp):
else:
body = self.fixtures.load('reboot_active.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
if __name__ == '__main__':
- sys.exit(unittest.main())
\ No newline at end of file
+ sys.exit(unittest.main())
Modified: incubator/libcloud/trunk/test/test_linode.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_linode.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_linode.py (original)
+++ incubator/libcloud/trunk/test/test_linode.py Wed May 5 00:13:51 2010
@@ -27,7 +27,7 @@ import httplib
class LinodeTest(unittest.TestCase, TestCaseMixin):
# The Linode test suite
-
+
def setUp(self):
LinodeNodeDriver.connectionCls.conn_classes = (None, LinodeMockHttp)
LinodeMockHttp.use_param = 'api_action'
@@ -41,7 +41,7 @@ class LinodeTest(unittest.TestCase, Test
self.assertEqual(node.name, 'api-node3')
self.assertTrue('75.127.96.245' in node.public_ip)
self.assertEqual(node.private_ip, [])
-
+
def test_reboot_node(self):
# An exception would indicate failure
node = self.driver.list_nodes()[0]
@@ -51,7 +51,7 @@ class LinodeTest(unittest.TestCase, Test
# An exception would indicate failure
node = self.driver.list_nodes()[0]
self.driver.destroy_node(node)
-
+
def test_create_node(self):
# Will exception on failure
node = self.driver.create_node(name="Test",
@@ -59,17 +59,17 @@ class LinodeTest(unittest.TestCase, Test
size=self.driver.list_sizes()[0],
image=self.driver.list_images()[6],
auth=NodeAuthPassword("test123"))
-
+
def test_list_sizes(self):
sizes = self.driver.list_sizes()
self.assertEqual(len(sizes), 10)
for size in sizes:
self.assertEqual(size.ram, int(size.name.split(" ")[1]))
-
+
def test_list_images(self):
images = self.driver.list_images()
self.assertEqual(len(images), 22)
-
+
def test_create_node_response(self):
# should return a node object
node = self.driver.create_node(name="node-name",
@@ -79,16 +79,16 @@ class LinodeTest(unittest.TestCase, Test
auth=NodeAuthPassword("foobar"))
self.assertTrue(isinstance(node, Node))
-
+
class LinodeMockHttp(MockHttp):
def _avail_datacenters(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"avail.datacenters","DATA":[{"DATACENTERID":2,"LOCATION":"Dallas, TX, USA"},{"DATACENTERID":3,"LOCATION":"Fremont, CA, USA"},{"DATACENTERID":4,"LOCATION":"Atlanta, GA, USA"},{"DATACENTERID":6,"LOCATION":"Newark, NJ, USA"}]}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _avail_linodeplans(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"avail.linodeplans","DATA":[{"AVAIL":{"2":27,"3":0,"4":0,"6":0},"DISK":16,"PRICE":19.95,"PLANID":1,"LABEL":"Linode 360","RAM":360,"XFER":200},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":24,"PRICE":29.95,"PLANID":2,"LABEL":"Linode 540","RAM":540,"XFER":300},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":32,"PRICE":39.95,"PLANID":3,"LABEL":"Linode 720","RAM":720,"XFER":400},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":48,"PRICE":59.95,"PLANID":4,"LABEL":"Linode 1080","RAM":1080,"XFER":600},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":64,"PRICE":79.95,"PLANID":5,"LABEL":"Linode 1440","RAM":1440,"XFER":800},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":128,"PRICE":159.95,"PLANID":6,"LABEL":"Linode 2880","RAM":2880,"XFER":1600},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":256,"PRICE":319.95,"PLANID":7,"LABEL":"Linode 5760","RAM":5760,"XFER":2000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":384,"PRICE":479.95,"PLANID":8,"LABEL":"Linode 8640","RAM":8640,"XFER":2
000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":512,"PRICE":639.95,"PLANID":9,"LABEL":"Linode 11520","RAM":11520,"XFER":2000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":640,"PRICE":799.95,"PLANID":10,"LABEL":"Linode 14400","RAM":14400,"XFER":2000}]}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _avail_distributions(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"avail.distributions","DATA":[{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Arch Linux 2007.08","MINIMAGESIZE":436,"DISTRIBUTIONID":38,"CREATE_DT":"2007-10-24 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Centos 5.0","MINIMAGESIZE":594,"DISTRIBUTIONID":32,"CREATE_DT":"2007-04-27 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Centos 5.2","MINIMAGESIZE":950,"DISTRIBUTIONID":46,"CREATE_DT":"2008-11-30 00:00:00.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":1,"LABEL":"Centos 5.2 64bit","MINIMAGESIZE":980,"DISTRIBUTIONID":47,"CREATE_DT":"2008-11-30 00:00:00.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":0,"LABEL":"Debian 4.0","MINIMAGESIZE":200,"DISTRIBUTIONID":28,"CREATE_DT":"2007-04-18 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":1,"LABEL":"Debian 4.0 64bit","MINIMAGESIZE":220,"DISTRIBUTIONID":48,"CREATE_DT":"2008-12-02 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Debian 5.0","MINIMAGESIZE":200,"DISTRIBUTIONID"
:50,"CREATE_DT":"2009-02-19 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":1,"LABEL":"Debian 5.0 64bit","MINIMAGESIZE":300,"DISTRIBUTIONID":51,"CREATE_DT":"2009-02-19 00:00:00.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":0,"LABEL":"Fedora 8","MINIMAGESIZE":740,"DISTRIBUTIONID":40,"CREATE_DT":"2007-11-09 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Fedora 9","MINIMAGESIZE":1175,"DISTRIBUTIONID":43,"CREATE_DT":"2008-06-09 15:15:21.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":0,"LABEL":"Gentoo 2007.0","MINIMAGESIZE":1800,"DISTRIBUTIONID":35,"CREATE_DT":"2007-08-29 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Gentoo 2008.0","MINIMAGESIZE":1500,"DISTRIBUTIONID":52,"CREATE_DT":"2009-03-20 00:00:00.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":1,"LABEL":"Gentoo 2008.0 64bit","MINIMAGESIZE":2500,"DISTRIBUTIONID":53,"CREATE_DT":"2009-04-04 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"OpenSUSE 11.0","MINIMAGESIZE":850,"DISTRIBUTIONID":44,"CREATE_DT":"2008-08-21
08:32:16.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Slackware 12.0","MINIMAGESIZE":315,"DISTRIBUTIONID":34,"CREATE_DT":"2007-07-16 00:00:00.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":0,"LABEL":"Slackware 12.2","MINIMAGESIZE":500,"DISTRIBUTIONID":54,"CREATE_DT":"2009-04-04 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Ubuntu 8.04 LTS","MINIMAGESIZE":400,"DISTRIBUTIONID":41,"CREATE_DT":"2008-04-23 15:11:29.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":1,"LABEL":"Ubuntu 8.04 LTS 64bit","MINIMAGESIZE":350,"DISTRIBUTIONID":42,"CREATE_DT":"2008-06-03 12:51:11.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Ubuntu 8.10","MINIMAGESIZE":220,"DISTRIBUTIONID":45,"CREATE_DT":"2008-10-30 23:23:03.0"},{"REQUIRESPVOPSKERNEL":1,"IS64BIT":1,"LABEL":"Ubuntu 8.10 64bit","MINIMAGESIZE":230,"DISTRIBUTIONID":49,"CREATE_DT":"2008-12-02 00:00:00.0"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":0,"LABEL":"Ubuntu 9.04","MINIMAGESIZE":350,"DISTRIBUTIONID":55,"CREATE_DT":"2009-04-23 00:00:00.0"},{"RE
QUIRESPVOPSKERNEL":0,"IS64BIT":1,"LABEL":"Ubuntu 9.04 64bit","MINIMAGESIZE":350,"DISTRIBUTIONID":56,"CREATE_DT":"2009-04-23 00:00:00.0"}]}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
@@ -96,31 +96,31 @@ class LinodeMockHttp(MockHttp):
def _linode_create(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.create","DATA":{"LinodeID":8098}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _linode_disk_createfromdistribution(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.disk.createFromDistribution","DATA":{"JobID":1298,"DiskID":55647}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _linode_delete(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.delete","DATA":{"LinodeID":8098}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _linode_reboot(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.reboot","DATA":{"JobID":1305}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _avail_kernels(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"avail.kernels","DATA":[{"LABEL":"Latest 2.6 Stable (2.6.18.8-linode19)","ISXEN":1,"KERNELID":60},{"LABEL":"2.6.18.8-linode19","ISXEN":1,"KERNELID":103},{"LABEL":"2.6.30.5-linode20","ISXEN":1,"KERNELID":105},{"LABEL":"Latest 2.6 Stable (2.6.18.8-x86_64-linode7)","ISXEN":1,"KERNELID":107},{"LABEL":"2.6.18.8-x86_64-linode7","ISXEN":1,"KERNELID":104},{"LABEL":"2.6.30.5-x86_64-linode8","ISXEN":1,"KERNELID":106},{"LABEL":"pv-grub-x86_32","ISXEN":1,"KERNELID":92},{"LABEL":"pv-grub-x86_64","ISXEN":1,"KERNELID":95},{"LABEL":"Recovery - Finnix (kernel)","ISXEN":1,"KERNELID":61},{"LABEL":"2.6.18.8-domU-linode7","ISXEN":1,"KERNELID":81},{"LABEL":"2.6.18.8-linode10","ISXEN":1,"KERNELID":89},{"LABEL":"2.6.18.8-linode16","ISXEN":1,"KERNELID":98},{"LABEL":"2.6.24.4-linode8","ISXEN":1,"KERNELID":84},{"LABEL":"2.6.25-linode9","ISXEN":1,"KERNELID":88},{"LABEL":"2.6.25.10-linode12","ISXEN":1,"KERNELID":90},{"LABEL":"2.6.26-linode13","ISXEN":1,"KERNELID
":91},{"LABEL":"2.6.27.4-linode14","ISXEN":1,"KERNELID":93},{"LABEL":"2.6.28-linode15","ISXEN":1,"KERNELID":96},{"LABEL":"2.6.28.3-linode17","ISXEN":1,"KERNELID":99},{"LABEL":"2.6.29-linode18","ISXEN":1,"KERNELID":101},{"LABEL":"2.6.16.38-x86_64-linode2","ISXEN":1,"KERNELID":85},{"LABEL":"2.6.18.8-x86_64-linode1","ISXEN":1,"KERNELID":86},{"LABEL":"2.6.27.4-x86_64-linode3","ISXEN":1,"KERNELID":94},{"LABEL":"2.6.28-x86_64-linode4","ISXEN":1,"KERNELID":97},{"LABEL":"2.6.28.3-x86_64-linode5","ISXEN":1,"KERNELID":100},{"LABEL":"2.6.29-x86_64-linode6","ISXEN":1,"KERNELID":102}]}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _linode_disk_create(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.disk.create","DATA":{"JobID":1299,"DiskID":55648}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _linode_boot(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.boot","DATA":{"JobID":1300}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _linode_config_create(self, method, url, body, headers):
body = '{"ERRORARRAY":[],"ACTION":"linode.config.create","DATA":{"ConfigID":31239}}'
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
Modified: incubator/libcloud/trunk/test/test_opennebula.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_opennebula.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_opennebula.py (original)
+++ incubator/libcloud/trunk/test/test_opennebula.py Wed May 5 00:13:51 2010
@@ -75,12 +75,12 @@ class OpenNebulaTests(unittest.TestCase,
class OpenNebulaMockHttp(MockHttp):
fixtures = FileFixtures('opennebula')
-
+
def _compute(self, method, url, body, headers):
if method == 'GET':
body = self.fixtures.load('computes.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
if method == 'POST':
body = self.fixtures.load('compute.xml')
return (httplib.CREATED, body, {}, httplib.responses[httplib.CREATED])
@@ -102,7 +102,7 @@ class OpenNebulaMockHttp(MockHttp):
if method == 'DELETE':
body = ""
return (httplib.NO_CONTENT, body, {}, httplib.responses[httplib.NO_CONTENT])
-
+
def _compute_15(self, method, url, body, headers):
if method == 'GET':
body = self.fixtures.load('compute.xml')
@@ -112,11 +112,11 @@ class OpenNebulaMockHttp(MockHttp):
if method == 'GET':
body = self.fixtures.load('disk.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _storage_8(self, method, url, body, headers):
if method == 'GET':
body = self.fixtures.load('disk.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
if __name__ == '__main__':
- sys.exit(unittest.main())
\ No newline at end of file
+ sys.exit(unittest.main())
Modified: incubator/libcloud/trunk/test/test_rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_rackspace.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_rackspace.py (original)
+++ incubator/libcloud/trunk/test/test_rackspace.py Wed May 5 00:13:51 2010
@@ -138,7 +138,7 @@ class RackspaceMockHttp(MockHttp):
def _v1_0_slug_images_detail(self, method, url, body, headers):
body = self.fixtures.load('v1_slug_images_detail.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
+
def _v1_0_slug_servers(self, method, url, body, headers):
body = self.fixtures.load('v1_slug_servers.xml')
return (httplib.ACCEPTED, body, {}, httplib.responses[httplib.ACCEPTED])
Modified: incubator/libcloud/trunk/test/test_rimuhosting.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_rimuhosting.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_rimuhosting.py (original)
+++ incubator/libcloud/trunk/test/test_rimuhosting.py Wed May 5 00:13:51 2010
@@ -63,7 +63,7 @@ class RimuHostingTest(unittest.TestCase,
# Raises exception on failure
node = self.driver.list_nodes()[0]
self.driver.destroy_node(node)
-
+
def test_create_node(self):
# Raises exception on failure
size = self.driver.list_sizes()[0]
Modified: incubator/libcloud/trunk/test/test_softlayer.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_softlayer.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_softlayer.py (original)
+++ incubator/libcloud/trunk/test/test_softlayer.py Wed May 5 00:13:51 2010
@@ -29,11 +29,11 @@ from test.file_fixtures import FileFixtu
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 = SoftLayerMockHttp(host, 80)
mock.request('POST', "%s/%s" % (handler, method))
resp = mock.getresponse()
Modified: incubator/libcloud/trunk/test/test_vcloud.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_vcloud.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_vcloud.py (original)
+++ incubator/libcloud/trunk/test/test_vcloud.py Wed May 5 00:13:51 2010
@@ -32,7 +32,7 @@ class TerremarkTests(unittest.TestCase,
def setUp(self):
VCloudNodeDriver.connectionCls.host = "test"
- VCloudNodeDriver.connectionCls.conn_classes = (None, TerremarkMockHttp)
+ VCloudNodeDriver.connectionCls.conn_classes = (None, TerremarkMockHttp)
TerremarkMockHttp.type = None
self.driver = TerremarkDriver(TERREMARK_USER, TERREMARK_SECRET)
@@ -43,22 +43,22 @@ class TerremarkTests(unittest.TestCase,
def test_list_sizes(self):
ret = self.driver.list_sizes()
self.assertEqual(ret[0].ram, 512)
-
+
def test_create_node(self):
image = self.driver.list_images()[0]
size = self.driver.list_sizes()[0]
node = self.driver.create_node(
- name='testerpart2',
- image=image,
+ name='testerpart2',
+ image=image,
size=size,
vdc='https://services.vcloudexpress.terremark.com/api/v0.8/vdc/224',
- network='https://services.vcloudexpress.terremark.com/api/v0.8/network/725',
+ network='https://services.vcloudexpress.terremark.com/api/v0.8/network/725',
cpus=2,
)
self.assertTrue(isinstance(node, Node))
self.assertEqual(node.id, 'https://services.vcloudexpress.terremark.com/api/v0.8/vapp/14031')
self.assertEqual(node.name, 'testerpart2')
-
+
def test_list_nodes(self):
ret = self.driver.list_nodes()
node = ret[0]
@@ -67,18 +67,18 @@ class TerremarkTests(unittest.TestCase,
self.assertEqual(node.state, NodeState.RUNNING)
self.assertEqual(node.public_ip, [])
self.assertEqual(node.private_ip, ['10.112.78.69'])
-
+
def test_reboot_node(self):
node = self.driver.list_nodes()[0]
ret = self.driver.reboot_node(node)
self.assertTrue(ret)
-
+
def test_destroy_node(self):
node = self.driver.list_nodes()[0]
ret = self.driver.destroy_node(node)
self.assertTrue(ret)
-
+
class TerremarkMockHttp(MockHttp):
fixtures = FileFixtures('terremark')
@@ -103,23 +103,23 @@ class TerremarkMockHttp(MockHttp):
def _api_v0_8_catalogItem_5(self, method, url, body, headers):
body = self.fixtures.load('api_v0_8_catalogItem_5.xml')
return (httplib.OK, body, headers, httplib.responses[httplib.OK])
-
+
def _api_v0_8_vdc_224_action_instantiateVAppTemplate(self, method, url, body, headers):
body = self.fixtures.load('api_v0_8_vdc_224_action_instantiateVAppTemplate.xml')
return (httplib.OK, body, headers, httplib.responses[httplib.OK])
-
+
def _api_v0_8_vapp_14031_action_deploy(self, method, url, body, headers):
body = self.fixtures.load('api_v0_8_vapp_14031_action_deploy.xml')
return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED])
-
+
def _api_v0_8_task_10496(self, method, url, body, headers):
body = self.fixtures.load('api_v0_8_task_10496.xml')
return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED])
-
+
def _api_v0_8_vapp_14031_power_action_powerOn(self, method, url, body, headers):
body = self.fixtures.load('api_v0_8_vapp_14031_power_action_powerOn.xml')
return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED])
-
+
def _api_v0_8_vapp_14031(self, method, url, body, headers):
if method == 'GET':
body = self.fixtures.load('api_v0_8_vapp_14031_get.xml')
Modified: incubator/libcloud/trunk/test/test_vpsnet.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_vpsnet.py?rev=941117&r1=941116&r2=941117&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_vpsnet.py (original)
+++ incubator/libcloud/trunk/test/test_vpsnet.py Wed May 5 00:13:51 2010
@@ -74,7 +74,7 @@ class VPSNetTests(unittest.TestCase, Tes
self.assertEqual(len(ret), 2)
self.assertEqual(ret[1].id, 2)
self.assertEqual(ret[1].name, '2 Node')
-
+
def test_destroy_node_response(self):
# should return a node object
node = Node('2222', None, None, None, None, self.driver)
@@ -115,21 +115,21 @@ class VPSNetMockHttp(MockHttp):
def _virtual_machines_1384_reboot_api10json_reboot(self, method, url, body, headers):
body = """{
- "virtual_machine":
+ "virtual_machine":
{
- "running": true,
- "updated_at": "2009-05-15T06:55:02-04:00",
- "power_action_pending": false,
- "system_template_id": 41,
- "id": 1384,
- "cloud_id": 3,
- "domain_name": "demodomain.com",
- "hostname": "web01",
- "consumer_id": 0,
- "backups_enabled": false,
- "password": "a8hjsjnbs91",
- "label": "foo",
- "slices_count": null,
+ "running": true,
+ "updated_at": "2009-05-15T06:55:02-04:00",
+ "power_action_pending": false,
+ "system_template_id": 41,
+ "id": 1384,
+ "cloud_id": 3,
+ "domain_name": "demodomain.com",
+ "hostname": "web01",
+ "consumer_id": 0,
+ "backups_enabled": false,
+ "password": "a8hjsjnbs91",
+ "label": "foo",
+ "slices_count": null,
"created_at": "2009-04-16T08:17:39-04:00"
}
}"""
@@ -137,21 +137,21 @@ class VPSNetMockHttp(MockHttp):
def _virtual_machines_api10json_create(self, method, url, body, headers):
body = """{
- "virtual_machine":
+ "virtual_machine":
{
- "running": true,
- "updated_at": "2009-05-15T06:55:02-04:00",
- "power_action_pending": false,
- "system_template_id": 41,
- "id": 1384,
- "cloud_id": 3,
- "domain_name": "demodomain.com",
- "hostname": "web01",
- "consumer_id": 0,
- "backups_enabled": false,
- "password": "a8hjsjnbs91",
- "label": "foo",
- "slices_count": null,
+ "running": true,
+ "updated_at": "2009-05-15T06:55:02-04:00",
+ "power_action_pending": false,
+ "system_template_id": 41,
+ "id": 1384,
+ "cloud_id": 3,
+ "domain_name": "demodomain.com",
+ "hostname": "web01",
+ "consumer_id": 0,
+ "backups_enabled": false,
+ "password": "a8hjsjnbs91",
+ "label": "foo",
+ "slices_count": null,
"created_at": "2009-04-16T08:17:39-04:00"
}
}"""
@@ -159,40 +159,40 @@ class VPSNetMockHttp(MockHttp):
def _virtual_machines_api10json_virtual_machines(self, method, url, body, headers):
body = """ [{
- "virtual_machine":
+ "virtual_machine":
{
- "running": true,
- "updated_at": "2009-05-15T06:55:02-04:00",
- "power_action_pending": false,
- "system_template_id": 41,
- "id": 1384,
- "cloud_id": 3,
- "domain_name": "demodomain.com",
- "hostname": "web01",
- "consumer_id": 0,
- "backups_enabled": false,
- "password": "a8hjsjnbs91",
- "label": "Web Server 01",
- "slices_count": null,
+ "running": true,
+ "updated_at": "2009-05-15T06:55:02-04:00",
+ "power_action_pending": false,
+ "system_template_id": 41,
+ "id": 1384,
+ "cloud_id": 3,
+ "domain_name": "demodomain.com",
+ "hostname": "web01",
+ "consumer_id": 0,
+ "backups_enabled": false,
+ "password": "a8hjsjnbs91",
+ "label": "Web Server 01",
+ "slices_count": null,
"created_at": "2009-04-16T08:17:39-04:00"
}
},
{
- "virtual_machine":
+ "virtual_machine":
{
- "running": true,
- "updated_at": "2009-05-15T06:55:02-04:00",
- "power_action_pending": false,
- "system_template_id": 41,
- "id": 1385,
- "cloud_id": 3,
- "domain_name": "demodomain.com",
- "hostname": "mysql01",
- "consumer_id": 0,
- "backups_enabled": false,
- "password": "dsi8h38hd2s",
- "label": "MySQL Server 01",
- "slices_count": null,
+ "running": true,
+ "updated_at": "2009-05-15T06:55:02-04:00",
+ "power_action_pending": false,
+ "system_template_id": 41,
+ "id": 1385,
+ "cloud_id": 3,
+ "domain_name": "demodomain.com",
+ "hostname": "mysql01",
+ "consumer_id": 0,
+ "backups_enabled": false,
+ "password": "dsi8h38hd2s",
+ "label": "MySQL Server 01",
+ "slices_count": null,
"created_at": "2009-04-16T08:17:39-04:00"
}
}]"""