libcloud.test package

Subpackages

Submodules

libcloud.test.file_fixtures module

class libcloud.test.file_fixtures.BackupFileFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

class libcloud.test.file_fixtures.ComputeFileFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

class libcloud.test.file_fixtures.ContainerFileFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

class libcloud.test.file_fixtures.DNSFileFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

class libcloud.test.file_fixtures.FileFixtures(fixtures_type, sub_dir='')[source]

Bases: object

load(file)[source]
class libcloud.test.file_fixtures.LoadBalancerFileFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

class libcloud.test.file_fixtures.OpenStackFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

class libcloud.test.file_fixtures.StorageFileFixtures(sub_dir='')[source]

Bases: libcloud.test.file_fixtures.FileFixtures

libcloud.test.test_connection module

class libcloud.test.test_connection.BaseConnectionClassTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_constructor()[source]
test_parse_proxy_url()[source]
class libcloud.test.test_connection.ConnectionClassTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]
tearDown()[source]
test_cache_busting()[source]
test_content_length()[source]
test_context_is_reset_after_request_has_finished()[source]
test_dont_allow_insecure()[source]
test_log_curl()[source]
test_retry_with_backoff()[source]
test_retry_with_sleep()[source]
test_retry_with_timeout()[source]

libcloud.test.test_file_fixtures module

class libcloud.test.test_file_fixtures.FileFixturesTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_failure()[source]
test_success()[source]

libcloud.test.test_httplib_ssl module

class libcloud.test.test_httplib_ssl.TestHttpLibSSLTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]
test_certifi_ca_bundle_in_search_path()[source]
test_connect_throws_friendly_error_message_on_ssl_wrap_connection_reset_by_peer(*args, **keywargs)[source]
test_custom_ca_path_using_env_var_doesnt_exist()[source]
test_custom_ca_path_using_env_var_exist()[source]
test_custom_ca_path_using_env_var_is_directory()[source]
test_setup_ca_cert(*args, **keywargs)[source]
test_setup_verify(*args, **keywargs)[source]

libcloud.test.test_init module

class libcloud.test.test_init.TestUtils(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_init_once_and_debug_mode()[source]

libcloud.test.test_pricing module

class libcloud.test.test_pricing.PricingTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_get_pricing_invalid_driver_type()[source]
test_get_pricing_invalid_file_path()[source]
test_get_pricing_not_in_cache()[source]
test_get_pricing_success()[source]
test_get_size_price()[source]
test_invalid_module_pricing_cache()[source]
test_invalid_pricing_cache()[source]
test_set_pricing()[source]

libcloud.test.test_response_classes module

class libcloud.test.test_response_classes.ResponseClassesTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]
test_JsonResponse_class_malformed_response()[source]
test_JsonResponse_class_success()[source]
test_JsonResponse_class_zero_length_body_strip()[source]
test_XmlResponse_class()[source]
test_XmlResponse_class_malformed_response()[source]
test_XmlResponse_class_zero_length_body_strip()[source]
test_deflate_encoding()[source]
test_gzip_encoding()[source]

libcloud.test.test_types module

class libcloud.test.test_types.TestLazyList(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]
tearDown()[source]
test_contains()[source]
test_empty_list()[source]
test_indexing()[source]
test_init()[source]
test_iterator()[source]
test_iterator_not_exhausted()[source]
test_len()[source]
test_repr()[source]

libcloud.test.test_utils module

class libcloud.test.test_utils.NetworkingUtilsTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_increment_ipv4_segments()[source]
test_is_public_and_is_private_subnet()[source]
test_is_valid_ip_address()[source]
test_join_ipv4_segments()[source]
class libcloud.test.test_utils.TestUtils(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]
tearDown()[source]
test_bchr()[source]
test_deprecated_warning()[source]
test_exhaust_iterator()[source]
test_exhaust_iterator_empty_iterator()[source]
test_get_driver()[source]
test_get_secure_random_string()[source]
test_guess_file_mime_type()[source]
test_hexadigits()[source]
test_in_development_warning()[source]
test_read_in_chunks_filelike()[source]
test_read_in_chunks_iterator()[source]
test_read_in_chunks_iterator_no_data()[source]
test_set_driver()[source]
test_unicode_urlquote()[source]
libcloud.test.test_utils.show_warning(msg, cat, fname, lno, line=None)[source]

Module contents

class libcloud.test.BaseMockHttpObject[source]

Bases: object

class libcloud.test.LibcloudTestCase(*args, **kwargs)[source]

Bases: unittest.case.TestCase

assertExecutedMethodCount(expected)[source]
setUp()[source]
class libcloud.test.MockHttp(host, port, *args, **kwargs)[source]

Bases: libcloud.test.BaseMockHttpObject

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)
>>> mock.request('GET', '/example/')
>>> response = mock.getresponse()
>>> response.body.read()
'Hello World!'
>>> response.status
200
>>> response.getheaders()
[('X-Foo', 'libcloud')]
>>> MockHttp.type = 'fail'
>>> mock.request('GET', '/example/')
>>> response = mock.getresponse()
>>> response.body.read()
'Oh Noes!'
>>> response.status
403
>>> response.getheaders()
[('X-Foo', 'fail')]
close()[source]
connect()[source]

Can’t think of anything to mock here.

getresponse()[source]
host = None
port = None
proxy_url = None
request(method, url, body=None, headers=None, raw=False)[source]
response = None
responseCls

alias of MockResponse

set_http_proxy(proxy_url)[source]
test = None
type = None
use_param = None
class libcloud.test.MockHttpTestCase(*args, **kwargs)[source]

Bases: libcloud.test.MockHttp, unittest.case.TestCase

assertUrlContainsQueryParams(url, expected_params, strict=False)[source]

Assert that provided url contains provided query parameters.

Parameters:
  • url (str) – URL to assert.
  • expected_params (dict) – Dictionary of expected query parameters.
  • strict (bool) – Assert that provided url contains only expected_params. (defaults to False)
runTest()[source]
class libcloud.test.MockRawResponse(connection)[source]

Bases: libcloud.test.BaseMockHttpObject

Mock RawResponse object suitable for testing.

headers
next()[source]
reason
response
responseCls

alias of MockResponse

status
type = None
class libcloud.test.MockResponse(status, body=None, headers=None, reason=None)[source]

Bases: object

A mock HTTPResponse

body = <StringIO.StringIO instance>
getheader(name, *args, **kwargs)[source]
getheaders()[source]
headers = {}
msg()[source]
next()[source]
read(*args, **kwargs)[source]
reason = ''
status = 0
version = 11
class libcloud.test.StorageMockHttp(host, port, *args, **kwargs)[source]

Bases: libcloud.test.MockHttp

endheaders()[source]
putheader(key, value)[source]
putrequest(method, action, skip_host=0, skip_accept_encoding=0)[source]
send(data)[source]
class libcloud.test.multipleresponse(f)[source]

Bases: object

A decorator that allows MockHttp objects to return multi responses

count = 0
func = None