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 2013/10/26 00:01:45 UTC
[5/9] Add new "lint" target to tox,
flake8 fixes in the whole codebase.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/storage/drivers/s3.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/s3.py b/libcloud/storage/drivers/s3.py
index c1cf3c0..dee2887 100644
--- a/libcloud/storage/drivers/s3.py
+++ b/libcloud/storage/drivers/s3.py
@@ -22,7 +22,6 @@ import sys
from hashlib import sha1
from xml.etree.ElementTree import Element, SubElement
-from libcloud.utils.py3 import PY3
from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import urlquote
from libcloud.utils.py3 import urlencode
@@ -241,7 +240,7 @@ class S3StorageDriver(StorageDriver):
:rtype: ``list`` of :class:`Object`
"""
return list(self.iterate_container_objects(container,
- ex_prefix=ex_prefix))
+ ex_prefix=ex_prefix))
def iterate_container_objects(self, container, ex_prefix=None):
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/storage/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/providers.py b/libcloud/storage/providers.py
index 7c77eb0..4148d28 100644
--- a/libcloud/storage/providers.py
+++ b/libcloud/storage/providers.py
@@ -19,45 +19,45 @@ from libcloud.storage.types import Provider
DRIVERS = {
Provider.DUMMY:
- ('libcloud.storage.drivers.dummy', 'DummyStorageDriver'),
+ ('libcloud.storage.drivers.dummy', 'DummyStorageDriver'),
Provider.CLOUDFILES:
- ('libcloud.storage.drivers.cloudfiles', 'CloudFilesStorageDriver'),
+ ('libcloud.storage.drivers.cloudfiles', 'CloudFilesStorageDriver'),
Provider.S3:
- ('libcloud.storage.drivers.s3', 'S3StorageDriver'),
+ ('libcloud.storage.drivers.s3', 'S3StorageDriver'),
Provider.S3_US_WEST:
- ('libcloud.storage.drivers.s3', 'S3USWestStorageDriver'),
+ ('libcloud.storage.drivers.s3', 'S3USWestStorageDriver'),
Provider.S3_US_WEST_OREGON:
- ('libcloud.storage.drivers.s3', 'S3USWestOregonStorageDriver'),
+ ('libcloud.storage.drivers.s3', 'S3USWestOregonStorageDriver'),
Provider.S3_EU_WEST:
- ('libcloud.storage.drivers.s3', 'S3EUWestStorageDriver'),
+ ('libcloud.storage.drivers.s3', 'S3EUWestStorageDriver'),
Provider.S3_AP_SOUTHEAST:
- ('libcloud.storage.drivers.s3', 'S3APSEStorageDriver'),
+ ('libcloud.storage.drivers.s3', 'S3APSEStorageDriver'),
Provider.S3_AP_NORTHEAST:
- ('libcloud.storage.drivers.s3', 'S3APNEStorageDriver'),
+ ('libcloud.storage.drivers.s3', 'S3APNEStorageDriver'),
Provider.NINEFOLD:
- ('libcloud.storage.drivers.ninefold', 'NinefoldStorageDriver'),
+ ('libcloud.storage.drivers.ninefold', 'NinefoldStorageDriver'),
Provider.GOOGLE_STORAGE:
- ('libcloud.storage.drivers.google_storage', 'GoogleStorageDriver'),
+ ('libcloud.storage.drivers.google_storage', 'GoogleStorageDriver'),
Provider.CLOUDFILES_SWIFT:
- ('libcloud.storage.drivers.cloudfiles',
- 'CloudFilesSwiftStorageDriver'),
+ ('libcloud.storage.drivers.cloudfiles', 'CloudFilesSwiftStorageDriver'),
Provider.NIMBUS:
- ('libcloud.storage.drivers.nimbus', 'NimbusStorageDriver'),
+ ('libcloud.storage.drivers.nimbus', 'NimbusStorageDriver'),
Provider.LOCAL:
- ('libcloud.storage.drivers.local', 'LocalStorageDriver'),
+ ('libcloud.storage.drivers.local', 'LocalStorageDriver'),
Provider.AZURE_BLOBS:
- ('libcloud.storage.drivers.azure_blobs', 'AzureBlobsStorageDriver'),
+ ('libcloud.storage.drivers.azure_blobs', 'AzureBlobsStorageDriver'),
# Deprecated
Provider.CLOUDFILES_US:
- ('libcloud.storage.drivers.cloudfiles', 'CloudFilesUSStorageDriver'),
+ ('libcloud.storage.drivers.cloudfiles', 'CloudFilesUSStorageDriver'),
Provider.CLOUDFILES_UK:
- ('libcloud.storage.drivers.cloudfiles', 'CloudFilesUKStorageDriver')
+ ('libcloud.storage.drivers.cloudfiles', 'CloudFilesUKStorageDriver')
}
def get_driver(provider):
return get_provider_driver(DRIVERS, provider)
+
def set_driver(provider, module, klass):
return set_provider_driver(DRIVERS, provider, module, klass)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/test/__init__.py b/libcloud/test/__init__.py
index 86fcc47..68fdae2 100644
--- a/libcloud/test/__init__.py
+++ b/libcloud/test/__init__.py
@@ -54,6 +54,7 @@ class LibcloudTestCase(unittest.TestCase):
'expected %d, but %d mock methods were executed'
% (expected, actual))
+
class multipleresponse(object):
"""
A decorator that allows MockHttp objects to return multi responses
@@ -108,6 +109,7 @@ class MockResponse(object):
def msg(self):
raise NotImplemented
+
class BaseMockHttpObject(object):
def _get_method_name(self, type, use_param, qs, path):
path = path.split('?')[0]
@@ -119,6 +121,7 @@ class BaseMockHttpObject(object):
meth_name = '%s_%s' % (meth_name, param)
return meth_name
+
class MockHttp(BaseMockHttpObject):
"""
A mock HTTP client/server suitable for testing purposes. This replaces
@@ -155,9 +158,9 @@ class MockHttp(BaseMockHttpObject):
response = None
type = None
- use_param = None # will use this param to namespace the request function
+ use_param = None # will use this param to namespace the request function
- test = None # TestCase instance which is using this mock
+ test = None # TestCase instance which is using this mock
def __init__(self, host, port, *args, **kwargs):
self.host = host
@@ -206,6 +209,7 @@ class MockHttp(BaseMockHttpObject):
return (httplib.FORBIDDEN, 'Oh Noes!', {'X-Foo': 'fail'},
httplib.responses[httplib.FORBIDDEN])
+
class MockHttpTestCase(MockHttp, unittest.TestCase):
# Same as the MockHttp class, but you can also use assertions in the
# classes which inherit from this one.
@@ -218,6 +222,7 @@ class MockHttpTestCase(MockHttp, unittest.TestCase):
def runTest(self):
pass
+
class StorageMockHttp(MockHttp):
def putrequest(self, method, action):
pass
@@ -231,6 +236,7 @@ class StorageMockHttp(MockHttp):
def send(self, data):
pass
+
class MockRawResponse(BaseMockHttpObject):
"""
Mock RawResponse object suitable for testing.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/common/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_cloudstack.py b/libcloud/test/common/test_cloudstack.py
index 38abbb4..5a86757 100644
--- a/libcloud/test/common/test_cloudstack.py
+++ b/libcloud/test/common/test_cloudstack.py
@@ -26,7 +26,7 @@ from libcloud.utils.py3 import urlparse
from libcloud.utils.py3 import b
from libcloud.utils.py3 import parse_qsl
-from libcloud.common.cloudstack import CloudStackConnection, CloudStackResponse
+from libcloud.common.cloudstack import CloudStackConnection
from libcloud.common.types import MalformedResponseError
from libcloud.test import MockHttpTestCase
@@ -34,6 +34,7 @@ from libcloud.test import MockHttpTestCase
async_delay = 0
+
class CloudStackMockDriver(object):
host = 'nonexistant.'
path = '/path'
@@ -43,6 +44,7 @@ class CloudStackMockDriver(object):
async_delay = 0
+
class CloudStackCommonTest(unittest.TestCase):
def setUp(self):
CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
@@ -102,7 +104,7 @@ class CloudStackCommonTest(unittest.TestCase):
'templateid': 17,
'zoneid': 23,
'networkids': 42
- }, 'gHTo7mYmadZ+zluKHzlEKb1i/QU='
+ }, 'gHTo7mYmadZ+zluKHzlEKb1i/QU='
), (
{
'command': 'deployVirtualMachine',
@@ -112,7 +114,7 @@ class CloudStackCommonTest(unittest.TestCase):
'templateid': 17,
'zoneid': 23,
'networkids': 42
- }, 'tAgfrreI1ZvWlWLClD3gu4+aKv4='
+ }, 'tAgfrreI1ZvWlWLClD3gu4+aKv4='
)
]
@@ -121,6 +123,7 @@ class CloudStackCommonTest(unittest.TestCase):
params = connection.add_default_params(case[0])
self.assertEqual(connection._make_signature(params), b(case[1]))
+
class CloudStackMockHttp(MockHttpTestCase):
ERROR_TEXT = 'ERROR TEXT'
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/common/test_google.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_google.py b/libcloud/test/common/test_google.py
index 35da4b2..ff082c3 100644
--- a/libcloud/test/common/test_google.py
+++ b/libcloud/test/common/test_google.py
@@ -26,13 +26,13 @@ except ImportError:
from libcloud.utils.py3 import httplib
-from libcloud.test import MockHttp, LibcloudTestCase, MockResponse
+from libcloud.test import MockHttp, LibcloudTestCase
from libcloud.common.google import (GoogleAuthError,
GoogleBaseAuthConnection,
GoogleInstalledAppAuthConnection,
GoogleServiceAcctAuthConnection,
GoogleBaseConnection)
-from libcloud.test.secrets import GCE_PARAMS, GCE_KEYWORD_PARAMS
+from libcloud.test.secrets import GCE_PARAMS
# Skip some tests if PyCrypto is unavailable
try:
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/__init__.py b/libcloud/test/compute/__init__.py
index 1ac4a11..42e478c 100644
--- a/libcloud/test/compute/__init__.py
+++ b/libcloud/test/compute/__init__.py
@@ -36,7 +36,7 @@ class TestCaseMixin(object):
self.assertTrue(size.ram is None or isinstance(size.ram, int))
self.assertTrue(size.disk is None or isinstance(size.disk, int))
self.assertTrue(size.bandwidth is None or
- isinstance(size.bandwidth, int))
+ isinstance(size.bandwidth, int))
# Check that price values are ints, floats, or None.
self.assertTrue(size.price is None or isinstance(size.price, float)
or isinstance(size.price, int))
@@ -70,8 +70,8 @@ class TestCaseMixin(object):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
node = self.driver.create_node(name='node-name',
- image=image,
- size=size)
+ image=image,
+ size=size)
self.assertTrue(isinstance(node, Node))
def test_destroy_node_response(self):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_avail_datacenters.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_avail_datacenters.json b/libcloud/test/compute/fixtures/linode/_avail_datacenters.json
new file mode 100644
index 0000000..2f8a36c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_avail_datacenters.json
@@ -0,0 +1 @@
+{"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"}]}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_avail_distributions.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_avail_distributions.json b/libcloud/test/compute/fixtures/linode/_avail_distributions.json
new file mode 100644
index 0000000..e2dbd0c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_avail_distributions.json
@@ -0,0 +1 @@
+{"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"},{"REQUIRESPVOPSKER
NEL":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"},{"REQUIRESPVOPSKERNEL":0,"IS64BIT":1,"LABEL"
:"Ubuntu 9.04 64bit","MINIMAGESIZE":350,"DISTRIBUTIONID":56,"CREATE_DT":"2009-04-23 00:00:00.0"}]}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_avail_kernels.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_avail_kernels.json b/libcloud/test/compute/fixtures/linode/_avail_kernels.json
new file mode 100644
index 0000000..457bb55
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_avail_kernels.json
@@ -0,0 +1 @@
+{"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}]}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_avail_linodeplans.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_avail_linodeplans.json b/libcloud/test/compute/fixtures/linode/_avail_linodeplans.json
new file mode 100644
index 0000000..37036d6
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_avail_linodeplans.json
@@ -0,0 +1 @@
+{"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 512","RAM":512,"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":2000},{"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}]}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_batch.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_batch.json b/libcloud/test/compute/fixtures/linode/_batch.json
new file mode 100644
index 0000000..3567259
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_batch.json
@@ -0,0 +1 @@
+[{"ACTION": "linode.ip.list", "DATA": [{"RDNS_NAME": "li22-54.members.linode.com", "ISPUBLIC": 1, "IPADDRESS": "75.127.96.54", "IPADDRESSID": 5384, "LINODEID": 8098}, {"RDNS_NAME": "li22-245.members.linode.com", "ISPUBLIC": 1, "IPADDRESS": "75.127.96.245", "IPADDRESSID": 5575, "LINODEID": 8098}], "ERRORARRAY": []}]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_linode_ip_list.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_linode_ip_list.json b/libcloud/test/compute/fixtures/linode/_linode_ip_list.json
new file mode 100644
index 0000000..53b8e91
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_linode_ip_list.json
@@ -0,0 +1 @@
+{"ACTION": "linode.ip.list", "DATA": [{"RDNS_NAME": "li22-54.members.linode.com", "ISPUBLIC": 1, "IPADDRESS": "75.127.96.54", "IPADDRESSID": 5384, "LINODEID": 8098}, {"RDNS_NAME": "li22-245.members.linode.com", "ISPUBLIC": 1, "IPADDRESS": "75.127.96.245", "IPADDRESSID": 5575, "LINODEID": 8098}], "ERRORARRAY": []}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/linode/_linode_list.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/linode/_linode_list.json b/libcloud/test/compute/fixtures/linode/_linode_list.json
new file mode 100644
index 0000000..93311e5
--- /dev/null
+++ b/libcloud/test/compute/fixtures/linode/_linode_list.json
@@ -0,0 +1 @@
+{"ACTION": "linode.list", "DATA": [{"ALERT_DISKIO_ENABLED": 1, "BACKUPWEEKLYDAY": 0, "LABEL": "api-node3", "DATACENTERID": 5, "ALERT_BWOUT_ENABLED": 1, "ALERT_CPU_THRESHOLD": 10, "TOTALHD": 100, "ALERT_BWQUOTA_THRESHOLD": 81, "ALERT_BWQUOTA_ENABLED": 1, "TOTALXFER": 200, "STATUS": 2, "ALERT_BWIN_ENABLED": 1, "ALERT_BWIN_THRESHOLD": 5, "ALERT_DISKIO_THRESHOLD": 200, "WATCHDOG": 1, "LINODEID": 8098, "BACKUPWINDOW": 1, "TOTALRAM": 512, "LPM_DISPLAYGROUP": "", "ALERT_BWOUT_THRESHOLD": 5, "BACKUPSENABLED": 1, "ALERT_CPU_ENABLED": 1}], "ERRORARRAY": []}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/fixtures/vpsnet/_available_clouds_api10json_templates.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/vpsnet/_available_clouds_api10json_templates.json b/libcloud/test/compute/fixtures/vpsnet/_available_clouds_api10json_templates.json
new file mode 100644
index 0000000..6b71959
--- /dev/null
+++ b/libcloud/test/compute/fixtures/vpsnet/_available_clouds_api10json_templates.json
@@ -0,0 +1 @@
+[{"cloud":{"system_templates":[{"id":9,"label":"Ubuntu 8.04 x64"},{"id":10,"label":"CentOS 5.2 x64"},{"id":11,"label":"Gentoo 2008.0 x64"},{"id":18,"label":"Ubuntu 8.04 x64 LAMP"},{"id":19,"label":"Ubuntu 8.04 x64 MySQL"},{"id":20,"label":"Ubuntu 8.04 x64 Postfix"},{"id":21,"label":"Ubuntu 8.04 x64 Apache"},{"id":22,"label":"CentOS 5.2 x64 MySQL"},{"id":23,"label":"CentOS 5.2 x64 LAMP"},{"id":24,"label":"CentOS 5.2 x64 HAProxy"},{"id":25,"label":"CentOS 5.2 x64 Postfix"},{"id":26,"label":"CentOS 5.2 x64 Varnish"},{"id":27,"label":"CentOS 5.2 x64 Shoutcast"},{"id":28,"label":"CentOS 5.2 x64 Apache"},{"id":40,"label":"cPanel"},{"id":42,"label":"Debian 5.0 (Lenny) x64"},{"id":58,"label":"Django on Ubuntu 8.04 (x86)"},{"id":59,"label":"Drupal 5 on Ubuntu 8.04 (x86)"},{"id":60,"label":"Drupal 6 on Ubuntu 8.04 (x86)"},{"id":61,"label":"Google App Engine on Ubuntu 8.04 (x86)"},{"id":62,"label":"LAMP on Ubuntu 8.04 (x86)"},{"id":63,"label":"LAPP on Ubuntu 8.04 (x86)"},{"id":64,"label":"Medi
aWiki on Ubuntu 8.04 (x86)"},{"id":65,"label":"MySQL on Ubuntu 8.04 (x86)"},{"id":66,"label":"phpBB on Ubuntu 8.04 (x86)"},{"id":67,"label":"PostgreSQL on Ubuntu 8.04 (x86)"},{"id":68,"label":"Rails on Ubuntu 8.04 (x86)"},{"id":69,"label":"Tomcat on Ubuntu 8.04 (x86)"},{"id":70,"label":"Wordpress on Ubuntu 8.04 (x86)"},{"id":71,"label":"Joomla on Ubuntu 8.04 (x86)"},{"id":72,"label":"Ubuntu 8.04 Default Install (turnkey)"},{"id":128,"label":"CentOS Optimised"},{"id":129,"label":"Optimised CentOS + Apache + MySQL + PHP"},{"id":130,"label":"Optimised CentOS + Apache + MySQL + Ruby"},{"id":131,"label":"Optimised CentOS + Apache + MySQL + Ruby + PHP"},{"id":132,"label":"Debian Optimised"},{"id":133,"label":"Optimised Debian + Apache + MySQL + PHP"},{"id":134,"label":"Optimised Debian + NGINX + MySQL + PHP"},{"id":135,"label":"Optimised Debian + Lighttpd + MySQL + PHP"},{"id":136,"label":"Optimised Debian + Apache + MySQL + Ruby + PHP"},{"id":137,"label":"Optimised Debian + Apache + MySQ
L + Ruby"},{"id":138,"label":"Optimised Debian + NGINX + MySQL + Ruby + PHP"},{"id":139,"label":"Optimised Debian + NGINX + MySQL + Ruby"},{"id":140,"label":"Optimised Debian + Apache + MySQL + PHP + Magento"},{"id":141,"label":"Optimised Debian + NGINX + MySQL + PHP + Magento"},{"id":142,"label":"Optimised Debian + Lighttpd + MySQL + PHP + Wordpress"}],"id":2,"label":"USA VPS Cloud"}},{"cloud":{"system_templates":[{"id":15,"label":"Ubuntu 8.04 x64"},{"id":16,"label":"CentOS 5.2 x64"},{"id":17,"label":"Gentoo 2008.0 x64"},{"id":29,"label":"Ubuntu 8.04 x64 LAMP"},{"id":30,"label":"Ubuntu 8.04 x64 MySQL"},{"id":31,"label":"Ubuntu 8.04 x64 Postfix"},{"id":32,"label":"Ubuntu 8.04 x64 Apache"},{"id":33,"label":"CentOS 5.2 x64 MySQL"},{"id":34,"label":"CentOS 5.2 x64 LAMP"},{"id":35,"label":"CentOS 5.2 x64 HAProxy"},{"id":36,"label":"CentOS 5.2 x64 Postfix"},{"id":37,"label":"CentOS 5.2 x64 Varnish"},{"id":38,"label":"CentOS 5.2 x64 Shoutcast"},{"id":39,"label":"CentOS 5.2 x64 Apache"},{"
id":41,"label":"cPanel"},{"id":43,"label":"Debian 5.0 (Lenny) x64"},{"id":44,"label":"Django on Ubuntu 8.04 (x86)"},{"id":45,"label":"Drupal 5 on Ubuntu 8.04 (x86)"},{"id":46,"label":"Drupal 6 on Ubuntu 8.04 (x86)"},{"id":47,"label":"Google App Engine on Ubuntu 8.04 (x86)"},{"id":48,"label":"LAMP on Ubuntu 8.04 (x86)"},{"id":49,"label":"LAPP on Ubuntu 8.04 (x86)"},{"id":50,"label":"MediaWiki on Ubuntu 8.04 (x86)"},{"id":51,"label":"MySQL on Ubuntu 8.04 (x86)"},{"id":52,"label":"phpBB on Ubuntu 8.04 (x86)"},{"id":53,"label":"PostgreSQL on Ubuntu 8.04 (x86)"},{"id":54,"label":"Rails on Ubuntu 8.04 (x86)"},{"id":55,"label":"Tomcat on Ubuntu 8.04 (x86)"},{"id":56,"label":"Wordpress on Ubuntu 8.04 (x86)"},{"id":57,"label":"Joomla on Ubuntu 8.04 (x86)"},{"id":73,"label":"Ubuntu 8.04 Default Install (turnkey)"},{"id":148,"label":"CentOS Optimised"},{"id":149,"label":"Optimised CentOS + Apache + MySQL + PHP"},{"id":150,"label":"Optimised CentOS + Apache + MySQL + Ruby"},{"id":151,"label":"O
ptimised CentOS + Apache + MySQL + Ruby + PHP"},{"id":152,"label":"Debian Optimised"},{"id":153,"label":"Optimised Debian + Apache + MySQL + PHP"},{"id":154,"label":"Optimised Debian + NGINX + MySQL + PHP"},{"id":155,"label":"Optimised Debian + Lighttpd + MySQL + PHP"},{"id":156,"label":"Optimised Debian + Apache + MySQL + Ruby + PHP"},{"id":157,"label":"Optimised Debian + Apache + MySQL + Ruby"},{"id":158,"label":"Optimised Debian + NGINX + MySQL + Ruby + PHP"},{"id":159,"label":"Optimised Debian + NGINX + MySQL + Ruby"},{"id":160,"label":"Optimised Debian + Lighttpd + MySQL + PHP + Wordpress"}],"id":3,"label":"UK VPS Cloud"}}]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_abiquo.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_abiquo.py b/libcloud/test/compute/test_abiquo.py
index dbd5626..152749f 100644
--- a/libcloud/test/compute/test_abiquo.py
+++ b/libcloud/test/compute/test_abiquo.py
@@ -32,9 +32,11 @@ from libcloud.test.file_fixtures import ComputeFileFixtures
class AbiquoNodeDriverTest(unittest.TestCase, TestCaseMixin):
+
"""
Abiquo Node Driver test suite
"""
+
def setUp(self):
"""
Set up the driver with the main user
@@ -267,6 +269,7 @@ class AbiquoNodeDriverTest(unittest.TestCase, TestCaseMixin):
class AbiquoMockHttp(MockHttpTestCase):
+
"""
Mock the functionallity of the remote Abiquo API.
"""
@@ -330,7 +333,8 @@ class AbiquoMockHttp(MockHttpTestCase):
def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_tasks_1da8c8b6_86f6_49ef_9d29_57dcc73b875a(self, method, url, body, headers):
if headers['Authorization'] == 'Basic bXV0ZW46cm9zaGk=':
# User 'muten:roshi' failed task
- response = self.fixtures.load('vdc_4_vapp_6_undeploy_task_failed.xml')
+ response = self.fixtures.load(
+ 'vdc_4_vapp_6_undeploy_task_failed.xml')
else:
response = self.fixtures.load('vdc_4_vapp_6_undeploy_task.xml')
return (httplib.OK, response, {}, '')
@@ -373,7 +377,8 @@ class AbiquoMockHttp(MockHttpTestCase):
response = self.fixtures.load('vdc_4_vapp_6_vm_3.xml')
return (httplib.OK, response, {}, '')
- def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_action_deploy(self, method, url, body, headers):
+ def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_action_deploy(self, method, url,
+ body, headers):
response = self.fixtures.load('vdc_4_vapp_6_vm_3_deploy.xml')
return (httplib.CREATED, response, {}, '')
@@ -381,7 +386,8 @@ class AbiquoMockHttp(MockHttpTestCase):
if headers['Authorization'] == 'Basic dGVuOnNoaW4=':
# User 'ten:shin' failed task
- response = self.fixtures.load('vdc_4_vapp_6_vm_3_deploy_task_failed.xml')
+ response = self.fixtures.load(
+ 'vdc_4_vapp_6_vm_3_deploy_task_failed.xml')
else:
response = self.fixtures.load('vdc_4_vapp_6_vm_3_deploy_task.xml')
return (httplib.OK, response, {}, '')
@@ -391,23 +397,27 @@ class AbiquoMockHttp(MockHttpTestCase):
response = self.fixtures.load('vdc_4_vapp_6_undeploy.xml')
return (httplib.OK, response, {}, '')
- def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_action_reset(self, method, url, body, headers):
+ def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_action_reset(self, method,
+ url, body, headers):
response = self.fixtures.load('vdc_4_vapp_6_vm_3_reset.xml')
return (httplib.CREATED, response, {}, '')
def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_tasks_a8c9818e_f389_45b7_be2c_3db3a9689940(self, method, url, body, headers):
if headers['Authorization'] == 'Basic bXV0ZW46cm9zaGk=':
# User 'muten:roshi' failed task
- response = self.fixtures.load('vdc_4_vapp_6_undeploy_task_failed.xml')
+ response = self.fixtures.load(
+ 'vdc_4_vapp_6_undeploy_task_failed.xml')
else:
response = self.fixtures.load('vdc_4_vapp_6_vm_3_reset_task.xml')
return (httplib.OK, response, {}, '')
- def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_action_undeploy(self, method, url, body, headers):
+ def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_action_undeploy(self, method, url,
+ body, headers):
response = self.fixtures.load('vdc_4_vapp_6_vm_3_undeploy.xml')
return (httplib.CREATED, response, {}, '')
- def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_network_nics(self, method, url, body, headers):
+ def _api_cloud_virtualdatacenters_4_virtualappliances_6_virtualmachines_3_network_nics(self, method, url,
+ body, headers):
response = self.fixtures.load('vdc_4_vapp_6_vm_3_nics.xml')
return (httplib.OK, response, {}, '')
@@ -438,8 +448,9 @@ class AbiquoMockHttp(MockHttpTestCase):
{}, '')
def _api_admin_enterprises_1_datacenterrepositories_2_virtualmachinetemplates_11(self, method, url, body, headers):
- return (httplib.OK, self.fixtures.load('ent_1_dcrep_2_template_11.xml'),
- {}, '')
+ return (
+ httplib.OK, self.fixtures.load('ent_1_dcrep_2_template_11.xml'),
+ {}, '')
if __name__ == '__main__':
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_base.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_base.py b/libcloud/test/compute/test_base.py
index 750d527..84edf95 100644
--- a/libcloud/test/compute/test_base.py
+++ b/libcloud/test/compute/test_base.py
@@ -23,9 +23,11 @@ from libcloud.compute.base import NodeAuthSSHKey, NodeAuthPassword
from libcloud.test import MockResponse # pylint: disable-msg=E0611
+
class FakeDriver(object):
type = 0
+
class BaseTests(unittest.TestCase):
def test_base_node(self):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_bluebox.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_bluebox.py b/libcloud/test/compute/test_bluebox.py
index a5b706c..bcee0a3 100644
--- a/libcloud/test/compute/test_bluebox.py
+++ b/libcloud/test/compute/test_bluebox.py
@@ -25,6 +25,7 @@ from libcloud.test import MockHttp
from libcloud.test.file_fixtures import ComputeFileFixtures
from libcloud.test.secrets import BLUEBOX_PARAMS
+
class BlueboxTest(unittest.TestCase):
def setUp(self):
@@ -33,10 +34,10 @@ class BlueboxTest(unittest.TestCase):
def test_create_node(self):
node = self.driver.create_node(
- name='foo',
- size=self.driver.list_sizes()[0],
- image=self.driver.list_images()[0],
- auth=NodeAuthPassword("test123")
+ name='foo',
+ size=self.driver.list_sizes()[0],
+ image=self.driver.list_images()[0],
+ auth=NodeAuthPassword("test123")
)
self.assertTrue(isinstance(node, Node))
self.assertEqual(node.state, NodeState.PENDING)
@@ -78,6 +79,7 @@ class BlueboxTest(unittest.TestCase):
ret = self.driver.destroy_node(node)
self.assertTrue(ret)
+
class BlueboxMockHttp(MockHttp):
fixtures = ComputeFileFixtures('bluebox')
@@ -99,13 +101,16 @@ class BlueboxMockHttp(MockHttp):
def _api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_json(self, method, url, body, headers):
if method == 'DELETE':
- body = self.fixtures.load('api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_json_delete.json')
+ body = self.fixtures.load(
+ 'api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_json_delete.json')
else:
- body = self.fixtures.load('api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_json.json')
+ body = self.fixtures.load(
+ 'api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_json.json')
return (httplib.OK, body, headers, httplib.responses[httplib.OK])
def _api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_reboot_json(self, method, url, body, headers):
- body = self.fixtures.load('api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_reboot_json.json')
+ body = self.fixtures.load(
+ 'api_blocks_99df878c_6e5c_4945_a635_d94da9fd3146_reboot_json.json')
return (httplib.OK, body, headers, httplib.responses[httplib.OK])
if __name__ == '__main__':
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_brightbox.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_brightbox.py b/libcloud/test/compute/test_brightbox.py
index b9f3ce2..651c349 100644
--- a/libcloud/test/compute/test_brightbox.py
+++ b/libcloud/test/compute/test_brightbox.py
@@ -23,7 +23,6 @@ except ImportError:
from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import b
-from libcloud.utils.py3 import u
from libcloud.common.types import InvalidCredsError
from libcloud.compute.drivers.brightbox import BrightboxNodeDriver
@@ -36,9 +35,12 @@ from libcloud.test.secrets import BRIGHTBOX_PARAMS
USER_DATA = '#!/bin/sh\ntest_script.sh\n'
+
class BrightboxTest(unittest.TestCase, TestCaseMixin):
+
def setUp(self):
- BrightboxNodeDriver.connectionCls.conn_classes = (None, BrightboxMockHttp)
+ BrightboxNodeDriver.connectionCls.conn_classes = (
+ None, BrightboxMockHttp)
BrightboxMockHttp.type = None
self.driver = BrightboxNodeDriver(*BRIGHTBOX_PARAMS)
@@ -70,7 +72,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
self.assertTrue('109.107.35.16' in nodes[0].public_ips)
self.assertTrue('10.74.210.210' in nodes[0].private_ips)
self.assertTrue('10.240.228.234' in nodes[1].private_ips)
- self.assertTrue('2a02:1348:14c:393a:24:19ff:fef0:e4ea' in nodes[1].public_ips)
+ self.assertTrue(
+ '2a02:1348:14c:393a:24:19ff:fef0:e4ea' in nodes[1].public_ips)
self.assertEqual(nodes[0].state, NodeState.RUNNING)
self.assertEqual(nodes[1].state, NodeState.RUNNING)
@@ -84,10 +87,10 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
self.assertEqual(nodes[0].size.id, 'typ-urtky')
self.assertEqual(nodes[1].image.id, 'img-j93gd')
self.assertEqual(nodes[1].size.id, 'typ-qdiwq')
- self.assertEqual(nodes[0].extra['fqdn'],'srv-xvpn7.gb1.brightbox.com')
- self.assertEqual(nodes[1].extra['fqdn'],'srv-742vn.gb1.brightbox.com')
- self.assertEqual(nodes[0].extra['hostname'],'srv-xvpn7')
- self.assertEqual(nodes[1].extra['hostname'],'srv-742vn')
+ self.assertEqual(nodes[0].extra['fqdn'], 'srv-xvpn7.gb1.brightbox.com')
+ self.assertEqual(nodes[1].extra['fqdn'], 'srv-742vn.gb1.brightbox.com')
+ self.assertEqual(nodes[0].extra['hostname'], 'srv-xvpn7')
+ self.assertEqual(nodes[1].extra['hostname'], 'srv-742vn')
self.assertEqual(nodes[0].extra['status'], 'active')
self.assertEqual(nodes[1].extra['status'], 'active')
self.assertTrue('interfaces' in nodes[0].extra)
@@ -154,7 +157,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
def test_create_node(self):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
- node = self.driver.create_node(name='Test Node', image=image, size=size)
+ node = self.driver.create_node(
+ name='Test Node', image=image, size=size)
self.assertEqual('srv-p61uj', node.id)
self.assertEqual('Test Node', node.name)
self.assertEqual('gb1-a', node.extra['zone'].name)
@@ -163,7 +167,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
location = self.driver.list_locations()[1]
- node = self.driver.create_node(name='Test Node', image=image, size=size,location = location)
+ node = self.driver.create_node(
+ name='Test Node', image=image, size=size, location=location)
self.assertEqual('srv-nnumd', node.id)
self.assertEqual('Test Node', node.name)
self.assertEqual('gb1-b', node.extra['zone'].name)
@@ -171,7 +176,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
def test_create_node_with_user_data(self):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
- node = self.driver.create_node(name='Test Node', image=image, size=size, ex_userdata=USER_DATA)
+ node = self.driver.create_node(
+ name='Test Node', image=image, size=size, ex_userdata=USER_DATA)
decoded = base64.b64decode(b(node.extra['user_data'])).decode('ascii')
self.assertEqual('gb1-a', node.extra['zone'].name)
self.assertEqual(USER_DATA, decoded)
@@ -179,7 +185,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
def test_create_node_with_a_server_group(self):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
- node = self.driver.create_node(name='Test Node', image=image, size=size, ex_servergroup='grp-12345')
+ node = self.driver.create_node(
+ name='Test Node', image=image, size=size, ex_servergroup='grp-12345')
self.assertEqual('gb1-a', node.extra['zone'].name)
self.assertEqual(len(node.extra['server_groups']), 1)
self.assertEqual(node.extra['server_groups'][0]['id'], 'grp-12345')
@@ -187,7 +194,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
def test_create_node_with_a_list_of_server_groups(self):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
- node = self.driver.create_node(name='Test Node', image=image, size=size, ex_servergroup=['grp-12345', 'grp-67890'])
+ node = self.driver.create_node(
+ name='Test Node', image=image, size=size, ex_servergroup=['grp-12345', 'grp-67890'])
self.assertEqual('gb1-a', node.extra['zone'].name)
self.assertEqual(len(node.extra['server_groups']), 2)
self.assertEqual(node.extra['server_groups'][0]['id'], 'grp-12345')
@@ -200,7 +208,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
cip_check = cip_list[0]
self.assertEqual(cip_check['id'], 'cip-tlrp3')
self.assertEqual(cip_check['public_ip'], '109.107.35.16')
- self.assertEqual(cip_check['reverse_dns'], 'cip-109-107-35-16.gb1.brightbox.com')
+ self.assertEqual(
+ cip_check['reverse_dns'], 'cip-109-107-35-16.gb1.brightbox.com')
self.assertEqual(cip_check['status'], 'unmapped')
self.assertTrue(cip_check['server'] is None)
self.assertTrue(cip_check['server_group'] is None)
@@ -210,7 +219,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
def test_create_cloud_ip(self):
cip = self.driver.ex_create_cloud_ip()
self.assertEqual(cip['id'], 'cip-jsjc5')
- self.assertEqual(cip['reverse_dns'], 'cip-109-107-37-234.gb1.brightbox.com')
+ self.assertEqual(
+ cip['reverse_dns'], 'cip-109-107-37-234.gb1.brightbox.com')
def test_create_cloud_ip_with_dns(self):
cip = self.driver.ex_create_cloud_ip('fred.co.uk')
@@ -224,7 +234,8 @@ class BrightboxTest(unittest.TestCase, TestCaseMixin):
self.assertTrue(self.driver.ex_unmap_cloud_ip('cip-jsjc5'))
def test_update_cloud_ip(self):
- self.assertTrue(self.driver.ex_update_cloud_ip('cip-jsjc5', 'fred.co.uk'))
+ self.assertTrue(
+ self.driver.ex_update_cloud_ip('cip-jsjc5', 'fred.co.uk'))
def test_destroy_cloud_ip(self):
self.assertTrue(self.driver.ex_destroy_cloud_ip('cip-jsjc5'))
@@ -257,14 +268,18 @@ class BrightboxMockHttp(MockHttp):
encoded = base64.b64encode(b(USER_DATA)).decode('ascii')
if 'user_data' in body and body['user_data'] != encoded:
- return self.response(httplib.BAD_REQUEST, '{"error_name":"dodgy user data", "errors": ["User data not encoded properly"]}')
+ data = '{"error_name":"dodgy user data", "errors": ["User data not encoded properly"]}'
+ return self.response(httplib.BAD_REQUEST, data)
if body.get('zone', '') == 'zon-remk1':
- node = json.loads(self.fixtures.load('create_server_gb1_b.json'))
+ node = json.loads(
+ self.fixtures.load('create_server_gb1_b.json'))
else:
- node = json.loads(self.fixtures.load('create_server_gb1_a.json'))
+ node = json.loads(
+ self.fixtures.load('create_server_gb1_a.json'))
node['name'] = body['name']
if 'server_groups' in body:
- node['server_groups'] = [{'id': x} for x in body['server_groups']]
+ node['server_groups'] = [{'id': x}
+ for x in body['server_groups']]
if 'user_data' in body:
node['user_data'] = body['user_data']
return self.response(httplib.ACCEPTED, json.dumps(node))
@@ -283,8 +298,10 @@ class BrightboxMockHttp(MockHttp):
return self.response(httplib.OK, "{}")
else:
return self.response(httplib.OK, self.fixtures.load('list_zones.json'))
+
def _2_0_zones(self, method, url, body, headers):
- return self.response(httplib.BAD_REQUEST, '{"error_name":"unrecognised_endpoint", "errors": ["The request was for an unrecognised API endpoint"]}')
+ data = '{"error_name":"unrecognised_endpoint", "errors": ["The request was for an unrecognised API endpoint"]}'
+ return self.response(httplib.BAD_REQUEST, data)
def _1_0_cloud_ips(self, method, url, body, headers):
if method == 'GET':
@@ -315,13 +332,13 @@ class BrightboxMockHttp(MockHttp):
if 'destination' in body:
return self.response(httplib.ACCEPTED, '')
else:
- return self.response(httplib.BAD_REQUEST, '{"error_name":"bad destination", "errors": ["Bad destination"]}')
+ data = '{"error_name":"bad destination", "errors": ["Bad destination"]}'
+ return self.response(httplib.BAD_REQUEST, data)
def _1_0_cloud_ips_cip_jsjc5_unmap(self, method, url, body, headers):
if method == 'POST':
return self.response(httplib.ACCEPTED, '')
-
def response(self, status, body):
return (status, body, {'content-type': 'application/json'}, httplib.responses[status])
@@ -329,5 +346,5 @@ class BrightboxMockHttp(MockHttp):
if __name__ == '__main__':
sys.exit(unittest.main())
-# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=python
-
+# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4
+# filetype=python
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudsigma.py b/libcloud/test/compute/test_cloudsigma.py
index 8c41f2c..ecbe63a 100644
--- a/libcloud/test/compute/test_cloudsigma.py
+++ b/libcloud/test/compute/test_cloudsigma.py
@@ -23,13 +23,14 @@ from libcloud.utils.misc import str2dicts, str2list, dict2str
from libcloud.test import MockHttp # pylint: disable-msg=E0611
from libcloud.test.compute import TestCaseMixin # pylint: disable-msg=E0611
-from libcloud.test.file_fixtures import ComputeFileFixtures # pylint: disable-msg=E0611
+from libcloud.test.file_fixtures import ComputeFileFixtures # pylint: disable-msg=E0611
class CloudSigmaTestCase(unittest.TestCase, TestCaseMixin):
+
def setUp(self):
CloudSigmaZrhNodeDriver.connectionCls.conn_classes = (None,
- CloudSigmaHttp)
+ CloudSigmaHttp)
self.driver = CloudSigmaZrhNodeDriver('foo', 'bar')
def test_list_nodes(self):
@@ -78,7 +79,7 @@ class CloudSigmaTestCase(unittest.TestCase, TestCaseMixin):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
node = self.driver.create_node(
- name="cloudsigma node", image=image, size = size)
+ name="cloudsigma node", image=image, size=size)
self.assertTrue(isinstance(node, Node))
def test_ex_static_ip_list(self):
@@ -131,6 +132,7 @@ class CloudSigmaTestCase(unittest.TestCase, TestCaseMixin):
self.assertTrue(result.find('cpu 2200') >= 0)
self.assertTrue(result.find('mem 1024') >= 0)
+
class CloudSigmaHttp(MockHttp):
fixtures = ComputeFileFixtures('cloudsigma')
@@ -139,29 +141,29 @@ class CloudSigmaHttp(MockHttp):
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_start(
- self, method, url, body, headers):
+ self, method, url, body, headers):
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_stop(
- self, method, url, body, headers):
+ self, method, url, body, headers):
return (httplib.NO_CONTENT, body, {}, httplib.responses[httplib.OK])
def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_destroy(
- self, method, url, body, headers):
+ self, method, url, body, headers):
return (httplib.NO_CONTENT,
body, {}, httplib.responses[httplib.NO_CONTENT])
def _drives_d18119ce_7afa_474a_9242_e0384b160220_clone(
- self, method, url, body, headers):
+ self, method, url, body, headers):
body = self.fixtures.load('drives_clone.txt')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _drives_a814def5_1789_49a0_bf88_7abe7bb1682a_info(
- self, method, url, body, headers):
+ self, method, url, body, headers):
body = self.fixtures.load('drives_single_info.txt')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
@@ -190,12 +192,12 @@ class CloudSigmaHttp(MockHttp):
return (httplib.NO_CONTENT, body, {}, httplib.responses[httplib.OK])
def _drives_d18119ce_7afa_474a_9242_e0384b160220_destroy(
- self, method, url, body, headers):
+ self, method, url, body, headers):
return (httplib.NO_CONTENT, body, {}, httplib.responses[httplib.OK])
def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_set(
- self, method, url, body, headers):
+ self, method, url, body, headers):
body = self.fixtures.load('servers_set.txt')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index 565fb05..546b182 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -20,17 +20,14 @@ from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import urlparse
from libcloud.utils.py3 import parse_qsl
-from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
-
try:
import simplejson as json
except ImportError:
import json
from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
-from libcloud.compute.types import DeploymentError, LibcloudError, Provider
+from libcloud.compute.types import LibcloudError, Provider
from libcloud.compute.providers import get_driver
-from libcloud.compute.base import Node, NodeImage, NodeSize, NodeLocation
from libcloud.test import unittest
from libcloud.test import MockHttpTestCase
@@ -39,6 +36,7 @@ from libcloud.test.file_fixtures import ComputeFileFixtures
class CloudStackNodeDriverTest(unittest.TestCase, TestCaseMixin):
+
def setUp(self):
CloudStackNodeDriver.connectionCls.conn_classes = \
(None, CloudStackMockHttp)
@@ -68,9 +66,9 @@ class CloudStackNodeDriverTest(unittest.TestCase, TestCaseMixin):
image = self.driver.list_images()[0]
CloudStackMockHttp.fixture_tag = 'deployfail'
try:
- node = self.driver.create_node(name='node-name',
- image=image,
- size=size)
+ self.driver.create_node(name='node-name',
+ image=image,
+ size=size)
except:
return
self.assertTrue(False)
@@ -80,9 +78,9 @@ class CloudStackNodeDriverTest(unittest.TestCase, TestCaseMixin):
image = self.driver.list_images()[0]
CloudStackMockHttp.fixture_tag = 'deployfail2'
try:
- node = self.driver.create_node(name='node-name',
- image=image,
- size=size)
+ self.driver.create_node(name='node-name',
+ image=image,
+ size=size)
except:
return
self.assertTrue(False)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_deployment.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_deployment.py b/libcloud/test/compute/test_deployment.py
index 6a10d24..dac9363 100644
--- a/libcloud/test/compute/test_deployment.py
+++ b/libcloud/test/compute/test_deployment.py
@@ -41,11 +41,13 @@ from libcloud.test.secrets import RACKSPACE_PARAMS
class MockDeployment(Deployment):
+
def run(self, node, client):
return node
class MockClient(BaseSSHClient):
+
def __init__(self, *args, **kwargs):
self.stdout = ''
self.stderr = ''
@@ -71,8 +73,8 @@ class DeploymentTests(unittest.TestCase):
self.driver.connection._populate_hosts_and_request_paths()
self.driver.features = {'create_node': ['generates_password']}
self.node = Node(id=12345, name='test', state=NodeState.RUNNING,
- public_ips=['1.2.3.4'], private_ips=['1.2.3.5'],
- driver=Rackspace)
+ public_ips=['1.2.3.4'], private_ips=['1.2.3.5'],
+ driver=Rackspace)
self.node2 = Node(id=123456, name='test', state=NodeState.RUNNING,
public_ips=['1.2.3.4'], private_ips=['1.2.3.5'],
driver=Rackspace)
@@ -90,7 +92,7 @@ class DeploymentTests(unittest.TestCase):
sshd = SSHKeyDeployment(key='1234')
self.assertEqual(self.node, sshd.run(node=self.node,
- client=MockClient(hostname='localhost')))
+ client=MockClient(hostname='localhost')))
def test_file_deployment(self):
# use this file (__file__) for obtaining permissions
@@ -99,20 +101,21 @@ class DeploymentTests(unittest.TestCase):
self.assertEqual(target, fd.target)
self.assertEqual(__file__, fd.source)
self.assertEqual(self.node, fd.run(
- node=self.node, client=MockClient(hostname='localhost')))
+ node=self.node, client=MockClient(hostname='localhost')))
def test_script_deployment(self):
sd1 = ScriptDeployment(script='foobar', delete=True)
sd2 = ScriptDeployment(script='foobar', delete=False)
- sd3 = ScriptDeployment(script='foobar', delete=False, name='foobarname')
+ sd3 = ScriptDeployment(
+ script='foobar', delete=False, name='foobarname')
self.assertTrue(sd1.name.find('deployment') != '1')
self.assertEqual(sd3.name, 'foobarname')
self.assertEqual(self.node, sd1.run(node=self.node,
- client=MockClient(hostname='localhost')))
+ client=MockClient(hostname='localhost')))
self.assertEqual(self.node, sd2.run(node=self.node,
- client=MockClient(hostname='localhost')))
+ client=MockClient(hostname='localhost')))
def test_script_file_deployment(self):
file_path = os.path.abspath(__file__)
@@ -185,6 +188,7 @@ class DeploymentTests(unittest.TestCase):
def test_script_deployment_and_sshkey_deployment_argument_types(self):
class FileObject(object):
+
def __init__(self, name):
self.name = name
@@ -214,29 +218,32 @@ class DeploymentTests(unittest.TestCase):
self.fail('TypeError was not thrown')
def test_wait_until_running_running_instantly(self):
- node2, ips = self.driver.wait_until_running(nodes=[self.node], wait_period=1,
- timeout=10)[0]
+ node2, ips = self.driver.wait_until_running(
+ nodes=[self.node], wait_period=1,
+ timeout=10)[0]
self.assertEqual(self.node.uuid, node2.uuid)
self.assertEqual(['67.23.21.33'], ips)
def test_wait_until_running_running_after_1_second(self):
RackspaceMockHttp.type = '1_SECOND_DELAY'
- node2, ips = self.driver.wait_until_running(nodes=[self.node], wait_period=1,
- timeout=10)[0]
+ node2, ips = self.driver.wait_until_running(
+ nodes=[self.node], wait_period=1,
+ timeout=10)[0]
self.assertEqual(self.node.uuid, node2.uuid)
self.assertEqual(['67.23.21.33'], ips)
def test_wait_until_running_running_after_1_second_private_ips(self):
RackspaceMockHttp.type = '1_SECOND_DELAY'
- node2, ips = self.driver.wait_until_running(nodes=[self.node], wait_period=1,
- timeout=10, ssh_interface='private_ips')[0]
+ node2, ips = self.driver.wait_until_running(
+ nodes=[self.node], wait_period=1,
+ timeout=10, ssh_interface='private_ips')[0]
self.assertEqual(self.node.uuid, node2.uuid)
self.assertEqual(['10.176.168.218'], ips)
def test_wait_until_running_invalid_ssh_interface_argument(self):
try:
self.driver.wait_until_running(nodes=[self.node], wait_period=1,
- ssh_interface='invalid')
+ ssh_interface='invalid')
except ValueError:
pass
else:
@@ -271,18 +278,20 @@ class DeploymentTests(unittest.TestCase):
try:
self.driver.wait_until_running(nodes=[self.node], wait_period=0.5,
- timeout=1)
+ timeout=1)
except LibcloudError:
e = sys.exc_info()[1]
- self.assertTrue(e.value.find('Unable to match specified uuids') != -1)
+ self.assertTrue(
+ e.value.find('Unable to match specified uuids') != -1)
else:
self.fail('Exception was not thrown')
def test_wait_until_running_running_wait_for_multiple_nodes(self):
RackspaceMockHttp.type = 'MULTIPLE_NODES'
- nodes = self.driver.wait_until_running(nodes=[self.node, self.node2], wait_period=0.5,
- timeout=1)
+ nodes = self.driver.wait_until_running(
+ nodes=[self.node, self.node2], wait_period=0.5,
+ timeout=1)
self.assertEqual(self.node.uuid, nodes[0][0].uuid)
self.assertEqual(self.node2.uuid, nodes[1][0].uuid)
self.assertEqual(['67.23.21.33'], nodes[0][1])
@@ -292,8 +301,9 @@ class DeploymentTests(unittest.TestCase):
mock_ssh_client = Mock()
mock_ssh_client.return_value = None
- ssh_client = self.driver._ssh_client_connect(ssh_client=mock_ssh_client,
- timeout=10)
+ ssh_client = self.driver._ssh_client_connect(
+ ssh_client=mock_ssh_client,
+ timeout=10)
self.assertEqual(mock_ssh_client, ssh_client)
def test_ssh_client_connect_timeout(self):
@@ -458,28 +468,34 @@ class RackspaceMockHttp(MockHttp):
httplib.responses[httplib.OK])
def _v1_0_slug_servers_detail(self, method, url, body, headers):
- body = self.fixtures.load('v1_slug_servers_detail_deployment_success.xml')
+ body = self.fixtures.load(
+ 'v1_slug_servers_detail_deployment_success.xml')
return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
def _v1_0_slug_servers_detail_1_SECOND_DELAY(self, method, url, body, headers):
time.sleep(1)
- body = self.fixtures.load('v1_slug_servers_detail_deployment_success.xml')
+ body = self.fixtures.load(
+ 'v1_slug_servers_detail_deployment_success.xml')
return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
def _v1_0_slug_servers_detail_TIMEOUT(self, method, url, body, headers):
- body = self.fixtures.load('v1_slug_servers_detail_deployment_pending.xml')
+ body = self.fixtures.load(
+ 'v1_slug_servers_detail_deployment_pending.xml')
return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
def _v1_0_slug_servers_detail_MISSING(self, method, url, body, headers):
- body = self.fixtures.load('v1_slug_servers_detail_deployment_missing.xml')
+ body = self.fixtures.load(
+ 'v1_slug_servers_detail_deployment_missing.xml')
return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
def _v1_0_slug_servers_detail_SAME_UUID(self, method, url, body, headers):
- body = self.fixtures.load('v1_slug_servers_detail_deployment_same_uuid.xml')
+ body = self.fixtures.load(
+ 'v1_slug_servers_detail_deployment_same_uuid.xml')
return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
def _v1_0_slug_servers_detail_MULTIPLE_NODES(self, method, url, body, headers):
- body = self.fixtures.load('v1_slug_servers_detail_deployment_multiple_nodes.xml')
+ body = self.fixtures.load(
+ 'v1_slug_servers_detail_deployment_multiple_nodes.xml')
return (httplib.OK, body, XML_HEADERS, httplib.responses[httplib.OK])
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_digitalocean.py b/libcloud/test/compute/test_digitalocean.py
index e6d8ab3..d96d22e 100644
--- a/libcloud/test/compute/test_digitalocean.py
+++ b/libcloud/test/compute/test_digitalocean.py
@@ -14,29 +14,25 @@
# limitations under the License.
import sys
import unittest
-import base64
try:
import simplejson as json
except ImportError:
- import json
+ import json # NOQA
from libcloud.utils.py3 import httplib
-from libcloud.utils.py3 import b
-from libcloud.utils.py3 import u
from libcloud.common.types import InvalidCredsError
from libcloud.compute.drivers.digitalocean import DigitalOceanNodeDriver
-from libcloud.compute.types import NodeState
from libcloud.test import MockHttp
-from libcloud.test.compute import TestCaseMixin
from libcloud.test.file_fixtures import ComputeFileFixtures
from libcloud.test.secrets import DIGITAL_OCEAN_PARAMS
-#class DigitalOceanTests(unittest.TestCase, TestCaseMixin):
+# class DigitalOceanTests(unittest.TestCase, TestCaseMixin):
class DigitalOceanTests(unittest.TestCase):
+
def setUp(self):
DigitalOceanNodeDriver.connectionCls.conn_classes = \
(None, DigitalOceanMockHttp)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_dreamhost.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dreamhost.py b/libcloud/test/compute/test_dreamhost.py
index 3839f97..d9cef5c 100644
--- a/libcloud/test/compute/test_dreamhost.py
+++ b/libcloud/test/compute/test_dreamhost.py
@@ -29,6 +29,7 @@ from libcloud.test import MockHttp
from libcloud.test.compute import TestCaseMixin
from libcloud.test.secrets import DREAMHOST_PARAMS
+
class DreamhostTest(unittest.TestCase, TestCaseMixin):
def setUp(self):
@@ -47,11 +48,11 @@ class DreamhostTest(unittest.TestCase, TestCaseMixin):
DreamhostMockHttp.type = 'BAD_AUTH'
try:
self.driver.list_nodes()
- self.assertTrue(False) # Above command should have thrown an InvalidCredsException
+ self.assertTrue(
+ False) # Above command should have thrown an InvalidCredsException
except InvalidCredsError:
self.assertTrue(True)
-
def test_list_nodes(self):
"""
Test list_nodes for DreamHost PS driver. Should return a list of two nodes:
@@ -207,74 +208,77 @@ class DreamhostTest(unittest.TestCase, TestCaseMixin):
def test_list_locations_response(self):
self.assertRaises(NotImplementedError, self.driver.list_locations)
+
class DreamhostMockHttp(MockHttp):
def _BAD_AUTH_dreamhost_ps_list_ps(self, method, url, body, headers):
- body = json.dumps({'data' : 'invalid_api_key', 'result' : 'error'})
+ body = json.dumps({'data': 'invalid_api_key', 'result': 'error'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _dreamhost_ps_add_ps(self, method, url, body, headers):
- body = json.dumps({'data' : {'added_web' : 'ps12345'}, 'result' : 'success'})
+ body = json.dumps(
+ {'data': {'added_web': 'ps12345'}, 'result': 'success'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _dreamhost_ps_list_ps(self, method, url, body, headers):
data = [{
- 'account_id' : 000000,
+ 'account_id': 000000,
'ip': '75.119.203.51',
- 'memory_mb' : 500,
- 'ps' : 'ps22174',
- 'start_date' : '2010-02-25',
- 'type' : 'web'
+ 'memory_mb': 500,
+ 'ps': 'ps22174',
+ 'start_date': '2010-02-25',
+ 'type': 'web'
},
- {
- 'account_id' : 000000,
- 'ip' : '75.119.203.52',
- 'memory_mb' : 1500,
- 'ps' : 'ps22175',
- 'start_date' : '2010-02-25',
- 'type' : 'mysql'
- }]
+ {
+ 'account_id': 000000,
+ 'ip': '75.119.203.52',
+ 'memory_mb': 1500,
+ 'ps': 'ps22175',
+ 'start_date': '2010-02-25',
+ 'type': 'mysql'
+ }]
result = 'success'
- body = json.dumps({'data' : data, 'result' : result})
+ body = json.dumps({'data': data, 'result': result})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _dreamhost_ps_list_images(self, method, url, body, headers):
data = [{
- 'description' : 'Private web server',
- 'image' : 'web'
+ 'description': 'Private web server',
+ 'image': 'web'
},
- {
- 'description' : 'Private MySQL server',
- 'image' : 'mysql'
- }]
+ {
+ 'description': 'Private MySQL server',
+ 'image': 'mysql'
+ }]
result = 'success'
- body = json.dumps({'data' : data, 'result' : result})
+ body = json.dumps({'data': data, 'result': result})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _dreamhost_ps_reboot(self, method, url, body, headers):
- body = json.dumps({'data' : 'reboot_scheduled', 'result' : 'success'})
+ body = json.dumps({'data': 'reboot_scheduled', 'result': 'success'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _API_FAILURE_dreamhost_ps_reboot(self, method, url, body, headers):
- body = json.dumps({'data' : 'no_such_ps', 'result' : 'error'})
+ body = json.dumps({'data': 'no_such_ps', 'result': 'error'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _dreamhost_ps_set_size(self, method, url, body, headers):
- body = json.dumps({'data' : {'memory-mb' : '500'}, 'result' : 'success'})
+ body = json.dumps(
+ {'data': {'memory-mb': '500'}, 'result': 'success'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _API_FAILURE_dreamhost_ps_set_size(self, method, url, body, headers):
- body = json.dumps({'data' : 'internal_error_setting_size', 'result' : 'error'})
+ body = json.dumps(
+ {'data': 'internal_error_setting_size', 'result': 'error'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _dreamhost_ps_remove_ps(self, method, url, body, headers):
- body = json.dumps({'data' : 'removed_web', 'result' : 'success'})
+ body = json.dumps({'data': 'removed_web', 'result': 'success'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
def _API_FAILURE_dreamhost_ps_remove_ps(self, method, url, body, headers):
- body = json.dumps({'data' : 'no_such_ps', 'result' : 'error'})
+ body = json.dumps({'data': 'no_such_ps', 'result': 'error'})
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
if __name__ == '__main__':
sys.exit(unittest.main())
-
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index c52f63a..9bfbfca 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -50,6 +50,7 @@ null_fingerprint = '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:' + \
class BaseEC2Tests(LibcloudTestCase):
+
def test_instantiate_driver_valid_regions(self):
regions = REGION_DETAILS.keys()
regions = [d for d in regions if d != 'nimbus']
@@ -397,7 +398,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
'dummy_rsa.pub')
with open(path, 'r') as fh:
- key = self.driver.ex_import_keypair_from_string('keypair', fh.read())
+ key = self.driver.ex_import_keypair_from_string(
+ 'keypair', fh.read())
self.assertEqual(key['keyName'], 'keypair')
self.assertEqual(key['keyFingerprint'], null_fingerprint)
@@ -421,9 +423,11 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
node1 = Node('i-4382922a', None, None, None, None, self.driver)
ip_addresses1 = self.driver.ex_describe_addresses_for_node(node1)
node2 = Node('i-4382922b', None, None, None, None, self.driver)
- ip_addresses2 = sorted(self.driver.ex_describe_addresses_for_node(node2))
+ ip_addresses2 = sorted(
+ self.driver.ex_describe_addresses_for_node(node2))
node3 = Node('i-4382922g', None, None, None, None, self.driver)
- ip_addresses3 = sorted(self.driver.ex_describe_addresses_for_node(node3))
+ ip_addresses3 = sorted(
+ self.driver.ex_describe_addresses_for_node(node3))
self.assertEqual(len(ip_addresses1), 1)
self.assertEqual(ip_addresses1[0], '1.2.3.4')
@@ -451,7 +455,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
def test_ex_describe_all_addresses(self):
EC2MockHttp.type = 'all_addresses'
elastic_ips1 = self.driver.ex_describe_all_addresses()
- elastic_ips2 = self.driver.ex_describe_all_addresses(only_allocated=True)
+ elastic_ips2 = self.driver.ex_describe_all_addresses(
+ only_allocated=True)
self.assertEqual(len(elastic_ips1), 3)
self.assertTrue('1.2.3.5' in elastic_ips1)
@@ -480,7 +485,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertTrue(ret)
def test_ex_change_node_size_same_size(self):
- size = NodeSize('m1.small', 'Small Instance', None, None, None, None, driver=self.driver)
+ size = NodeSize('m1.small', 'Small Instance',
+ None, None, None, None, driver=self.driver)
node = Node('i-4382922a', None, None, None, None, self.driver,
extra={'instancetype': 'm1.small'})
@@ -492,7 +498,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.fail('Same size was passed, but an exception was not thrown')
def test_ex_change_node_size(self):
- size = NodeSize('m1.large', 'Small Instance', None, None, None, None, driver=self.driver)
+ size = NodeSize('m1.large', 'Small Instance',
+ None, None, None, None, driver=self.driver)
node = Node('i-4382922a', None, None, None, None, self.driver,
extra={'instancetype': 'm1.small'})
@@ -906,6 +913,7 @@ class EucMockHttp(EC2MockHttp):
class NimbusTests(EC2Tests):
+
def setUp(self):
NimbusNodeDriver.connectionCls.conn_classes = (None, EC2MockHttp)
EC2MockHttp.use_param = 'Action'
@@ -951,7 +959,8 @@ class NimbusTests(EC2Tests):
self.assertEqual(node.id, 'i-8474834a')
self.assertEqual(len(node.public_ips), 1)
self.assertEqual(public_ips[0], '1.2.3.5')
- self.assertEqual(node.extra['tags'], {'user_key0': 'user_val0', 'user_key1': 'user_val1'})
+ self.assertEqual(node.extra['tags'], {
+ 'user_key0': 'user_val0', 'user_key1': 'user_val1'})
def test_ex_create_tags(self):
# Nimbus doesn't support creating tags so this one should be a
@@ -962,6 +971,7 @@ class NimbusTests(EC2Tests):
class EucTests(LibcloudTestCase, TestCaseMixin):
+
def setUp(self):
EucNodeDriver.connectionCls.conn_classes = (None, EucMockHttp)
EC2MockHttp.use_param = 'Action'
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_ecp.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ecp.py b/libcloud/test/compute/test_ecp.py
index c039797..c39875c 100644
--- a/libcloud/test/compute/test_ecp.py
+++ b/libcloud/test/compute/test_ecp.py
@@ -25,14 +25,14 @@ from libcloud.test.file_fixtures import ComputeFileFixtures
from libcloud.test.secrets import ECP_PARAMS
+
class ECPTests(unittest.TestCase, TestCaseMixin):
def setUp(self):
ECPNodeDriver.connectionCls.conn_classes = (None,
- ECPMockHttp)
+ ECPMockHttp)
self.driver = ECPNodeDriver(*ECP_PARAMS)
-
def test_list_nodes(self):
nodes = self.driver.list_nodes()
self.assertEqual(len(nodes), 2)
@@ -42,7 +42,6 @@ class ECPTests(unittest.TestCase, TestCaseMixin):
self.assertEqual(node.public_ips[0], "42.78.124.75")
self.assertEqual(node.state, NodeState.RUNNING)
-
def test_list_sizes(self):
sizes = self.driver.list_sizes()
self.assertEqual(len(sizes), 3)
@@ -56,9 +55,12 @@ class ECPTests(unittest.TestCase, TestCaseMixin):
def test_list_images(self):
images = self.driver.list_images()
self.assertEqual(len(images), 2)
- self.assertEqual(images[0].name, "centos54: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
+ self.assertEqual(
+ images[0].name, "centos54: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
self.assertEqual(images[0].id, "1")
- self.assertEqual(images[1].name, "centos54 two: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
+
+ name = "centos54 two: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2"
+ self.assertEqual(images[1].name, name)
self.assertEqual(images[1].id, "2")
def test_reboot_node(self):
@@ -75,10 +77,12 @@ class ECPTests(unittest.TestCase, TestCaseMixin):
# Raises exception on failure
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
- node = self.driver.create_node(name="api.ivan.net.nz", image=image, size=size)
+ 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 = ComputeFileFixtures('ecp')
@@ -123,6 +127,5 @@ class ECPMockHttp(MockHttp):
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
if __name__ == '__main__':
sys.exit(unittest.main())
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_elasticstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_elasticstack.py b/libcloud/test/compute/test_elasticstack.py
index 530c12d..31896c8 100644
--- a/libcloud/test/compute/test_elasticstack.py
+++ b/libcloud/test/compute/test_elasticstack.py
@@ -91,7 +91,8 @@ class ElasticStackTestCase(object):
except ElasticStackException:
pass
else:
- self.fail('Invalid option specified, but an exception was not thrown')
+ self.fail(
+ 'Invalid option specified, but an exception was not thrown')
def test_list_nodes(self):
nodes = self.driver.list_nodes()
@@ -102,7 +103,8 @@ class ElasticStackTestCase(object):
self.assertEqual(node.public_ips[0], "1.2.3.4")
self.assertEqual(node.public_ips[1], "1.2.3.5")
self.assertEqual(node.extra['smp'], 1)
- self.assertEqual(node.extra['ide:0:0'], "b6049e7a-aa1b-47f9-b21d-cdf2354e28d3")
+ self.assertEqual(
+ node.extra['ide:0:0'], "b6049e7a-aa1b-47f9-b21d-cdf2354e28d3")
def test_list_sizes(self):
images = self.driver.list_sizes()
@@ -120,7 +122,8 @@ class ElasticStackTestCase(object):
self.assertEqual(len(images), len(self.driver._standard_drives))
for uuid, values in list(self.driver._standard_drives.items()):
- self.assertEqual(len([image for image in images if image.id == uuid]), 1)
+ self.assertEqual(
+ len([image for image in images if image.id == uuid]), 1)
def test_reboot_node(self):
node = self.driver.list_nodes()[0]
@@ -223,15 +226,21 @@ class ElasticStackMockHttp(MockHttp):
body = self.fixtures.load('drives_create.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
- def _drives_0012e24a_6eae_4279_9912_3432f698cec8_image_38df0986_4d85_4b76_b502_3878ffc80161_gunzip(self, method, url, body, headers):
+ def _drives_0012e24a_6eae_4279_9912_3432f698cec8_image_38df0986_4d85_4b76_b502_3878ffc80161_gunzip(self, method,
+ url, body,
+ headers):
# ElasticHosts image
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
- def _drives_0012e24a_6eae_4279_9912_3432f698cec8_image_90aa51f2_15c0_4cff_81ee_e93aa20b9468_gunzip(self, method, url, body, headers):
+ def _drives_0012e24a_6eae_4279_9912_3432f698cec8_image_90aa51f2_15c0_4cff_81ee_e93aa20b9468_gunzip(self, method,
+ url, body,
+ headers):
# Skalikloud image
return (httplib.NO_CONTENT, body, {}, httplib.responses[httplib.NO_CONTENT])
- def _drives_0012e24a_6eae_4279_9912_3432f698cec8_image_679f5f44_0be7_4745_a658_cccd4334c1aa_gunzip(self, method, url, body, headers):
+ def _drives_0012e24a_6eae_4279_9912_3432f698cec8_image_679f5f44_0be7_4745_a658_cccd4334c1aa_gunzip(self, method,
+ url, body,
+ headers):
# ServerLove image
return (httplib.NO_CONTENT, body, {}, httplib.responses[httplib.NO_CONTENT])
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_gandi.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gandi.py b/libcloud/test/compute/test_gandi.py
index b6aef09..e4a11e8 100644
--- a/libcloud/test/compute/test_gandi.py
+++ b/libcloud/test/compute/test_gandi.py
@@ -156,6 +156,7 @@ class GandiTests(unittest.TestCase):
class GandiRatingTests(unittest.TestCase):
+
"""Tests where rating model is involved"""
node_name = 'test2'
@@ -192,7 +193,6 @@ class GandiRatingTests(unittest.TestCase):
self.assertEqual(node.name, self.node_name)
-
class GandiMockHttp(BaseGandiMockHttp):
fixtures = ComputeFileFixtures('gandi')
@@ -287,6 +287,7 @@ class GandiMockHttp(BaseGandiMockHttp):
class GandiMockRatingHttp(BaseGandiMockHttp):
+
"""Fixtures needed for tests related to rating model"""
fixtures = ComputeFileFixtures('gandi')
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index 747faef..2585e73 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -24,16 +24,14 @@ from libcloud.compute.drivers.gce import (GCENodeDriver, API_VERSION,
timestamp_to_datetime,
GCEAddress, GCEHealthCheck,
GCEFirewall, GCEForwardingRule,
- GCENetwork, GCENodeSize, GCEProject,
- GCERegion, GCETargetPool, GCEZone)
+ GCENetwork,
+ GCEZone)
from libcloud.common.google import (GoogleBaseAuthConnection,
GoogleInstalledAppAuthConnection,
GoogleBaseConnection,
- ResourceNotFoundError, ResourceExistsError,
- QuotaExceededError)
+ ResourceNotFoundError, ResourceExistsError)
from libcloud.test.common.test_google import GoogleAuthMockHttp
-from libcloud.compute.base import (Node, NodeImage, NodeSize, NodeLocation,
- StorageVolume)
+from libcloud.compute.base import Node, StorageVolume
from libcloud.test import MockHttpTestCase, LibcloudTestCase
from libcloud.test.compute import TestCaseMixin
@@ -43,6 +41,7 @@ from libcloud.test.secrets import GCE_PARAMS, GCE_KEYWORD_PARAMS
class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
+
"""
Google Compute Engine Test Class.
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a73a3bd8/libcloud/test/compute/test_gogrid.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gogrid.py b/libcloud/test/compute/test_gogrid.py
index 65b9327..f7ceae6 100644
--- a/libcloud/test/compute/test_gogrid.py
+++ b/libcloud/test/compute/test_gogrid.py
@@ -27,7 +27,8 @@ from libcloud.compute.base import Node, NodeImage, NodeSize
from libcloud.test import MockHttp # pylint: disable-msg=E0611
from libcloud.test.compute import TestCaseMixin # pylint: disable-msg=E0611
-from libcloud.test.file_fixtures import ComputeFileFixtures # pylint: disable-msg=E0611
+from libcloud.test.file_fixtures import ComputeFileFixtures # pylint: disable-msg=E0611
+
class GoGridTests(unittest.TestCase, TestCaseMixin):
@@ -90,9 +91,10 @@ class GoGridTests(unittest.TestCase, TestCaseMixin):
self.assertEqual(image.name, 'CentOS 5.3 (32-bit) w/ None')
self.assertEqual(image.id, '1531')
- location = NodeLocation(id='gogrid/GSI-939ef909-84b8-4a2f-ad56-02ccd7da05ff.img',
- name='test location', country='Slovenia',
- driver=self.driver)
+ location = NodeLocation(
+ id='gogrid/GSI-939ef909-84b8-4a2f-ad56-02ccd7da05ff.img',
+ name='test location', country='Slovenia',
+ driver=self.driver)
images = self.driver.list_images(location=location)
image = images[0]
self.assertEqual(len(images), 4)
@@ -154,7 +156,7 @@ class GoGridTests(unittest.TestCase, TestCaseMixin):
def test_ex_edit_image(self):
image = self.driver.list_images()[0]
ret = self.driver.ex_edit_image(image=image, public=False,
- ex_description="test", name="testname")
+ ex_description="test", name="testname")
self.assertTrue(isinstance(ret, NodeImage))
@@ -170,14 +172,14 @@ class GoGridTests(unittest.TestCase, TestCaseMixin):
ips = self.driver.ex_list_ips()
expected_ips = {"192.168.75.66": GoGridIpAddress(id="5348099",
- ip="192.168.75.66", public=True, state="Unassigned",
- subnet="192.168.75.64/255.255.255.240"),
- "192.168.75.67": GoGridIpAddress(id="5348100",
- ip="192.168.75.67", public=True, state="Assigned",
- subnet="192.168.75.64/255.255.255.240"),
- "192.168.75.68": GoGridIpAddress(id="5348101",
- ip="192.168.75.68", public=False, state="Unassigned",
- subnet="192.168.75.64/255.255.255.240")}
+ ip="192.168.75.66", public=True, state="Unassigned",
+ subnet="192.168.75.64/255.255.255.240"),
+ "192.168.75.67": GoGridIpAddress(id="5348100",
+ ip="192.168.75.67", public=True, state="Assigned",
+ subnet="192.168.75.64/255.255.255.240"),
+ "192.168.75.68": GoGridIpAddress(id="5348101",
+ ip="192.168.75.68", public=False, state="Unassigned",
+ subnet="192.168.75.64/255.255.255.240")}
self.assertEqual(len(expected_ips), 3)
@@ -195,6 +197,7 @@ class GoGridTests(unittest.TestCase, TestCaseMixin):
state = self.driver._get_state('invalid')
self.assertEqual(state, NodeState.UNKNOWN)
+
class GoGridMockHttp(MockHttp):
fixtures = ComputeFileFixtures('gogrid')
@@ -270,7 +273,7 @@ class GoGridMockHttp(MockHttp):
lookup = parse_qs(urlparse.urlparse(url).query)["lookup"][0]
if lookup in _valid_lookups:
fixture_path = "lookup_list_%s.json" % \
- (lookup.replace(".", "_"))
+ (lookup.replace(".", "_"))
else:
raise NotImplementedError
body = self.fixtures.load(fixture_path)