summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFelix Yan <felixonmars@gmail.com>2014-09-14 11:43:53 +0800
committerFelix Yan <felixonmars@gmail.com>2014-09-14 11:43:53 +0800
commit6733d6065583d098276d66f31a431b0dfc25810f (patch)
tree7601d63dcf2ee1629275b64b974d1ba24b2be270 /tests
parentd149a870b7315fb663eeffb5d4beba2d841ea3d1 (diff)
downloadboto-6733d6065583d098276d66f31a431b0dfc25810f.tar.gz
common modules: tidy up to meet PEP8 better
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py2
-rw-r--r--tests/integration/__init__.py2
-rwxr-xr-xtests/test.py3
-rw-r--r--tests/unit/__init__.py2
-rw-r--r--tests/unit/test_connection.py29
-rw-r--r--tests/unit/test_exception.py17
-rw-r--r--tests/unit/test_regioninfo.py2
7 files changed, 34 insertions, 23 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index b3fc3a0c..771ca94b 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -14,7 +14,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py
index ed359279..f03a609b 100644
--- a/tests/integration/__init__.py
+++ b/tests/integration/__init__.py
@@ -24,6 +24,7 @@
Base class to make checking the certs easier.
"""
+
# We subclass from ``object`` instead of ``TestCase`` here so that this doesn't
# add noise to the test suite (otherwise these no-ops would run on every
# import).
@@ -60,4 +61,3 @@ class ServiceCertVerificationTest(object):
always succeed (like fetch a list, even if it's empty).
"""
pass
-
diff --git a/tests/test.py b/tests/test.py
index 7e91af35..692ed4dd 100755
--- a/tests/test.py
+++ b/tests/test.py
@@ -71,6 +71,7 @@ PY3_WHITELIST = (
'tests/unit/test_regioninfo.py',
)
+
def main(whitelist=[]):
description = ("Runs boto unit and/or integration tests. "
"Arguments will be passed on to nosetests. "
@@ -83,7 +84,7 @@ def main(whitelist=[]):
known_args, remaining_args = parser.parse_known_args()
attribute_args = []
for service_attribute in known_args.service_tests:
- attribute_args.extend(['-a', '!notdefault,' +service_attribute])
+ attribute_args.extend(['-a', '!notdefault,' + service_attribute])
if not attribute_args:
# If the user did not specify any filtering criteria, we at least
# will filter out any test tagged 'notdefault'.
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index 56d386f8..9751decd 100644
--- a/tests/unit/__init__.py
+++ b/tests/unit/__init__.py
@@ -1,6 +1,7 @@
from boto.compat import http_client
from tests.compat import mock, unittest
+
class AWSMockServiceTestCase(unittest.TestCase):
"""Base class for mocking aws services."""
# This param is used by the unittest module to display a full
@@ -46,6 +47,7 @@ class AWSMockServiceTestCase(unittest.TestCase):
response.getheaders.return_value = header
response.msg = dict(header)
+
def overwrite_header(arg, default=None):
header_dict = dict(header)
if arg in header_dict:
diff --git a/tests/unit/test_connection.py b/tests/unit/test_connection.py
index 97514361..432e44e9 100644
--- a/tests/unit/test_connection.py
+++ b/tests/unit/test_connection.py
@@ -72,6 +72,7 @@ class MockAWSService(AWSQueryConnection):
"""
APIVersion = '2012-01-01'
+
def _required_auth_capability(self):
return ['sign-v2']
@@ -95,6 +96,7 @@ class MockAWSService(AWSQueryConnection):
validate_certs=validate_certs,
profile_name=profile_name)
+
class TestAWSAuthConnection(unittest.TestCase):
def test_get_path(self):
conn = AWSAuthConnection(
@@ -182,8 +184,9 @@ class TestAWSAuthConnection(unittest.TestCase):
'testhost',
aws_access_key_id='access_key',
aws_secret_access_key='secret')
- request = conn.build_base_http_request(method='POST', path='/',
- auth_path=None, params=None, headers=None, data='', host=None)
+ request = conn.build_base_http_request(
+ method='POST', path='/', auth_path=None, params=None, headers=None,
+ data='', host=None)
conn.set_host_header(request)
self.assertEqual(request.headers['Host'], 'testhost')
@@ -193,15 +196,17 @@ class TestAWSAuthConnection(unittest.TestCase):
aws_access_key_id='access_key',
aws_secret_access_key='secret',
port=8773)
- request = conn.build_base_http_request(method='POST', path='/',
- auth_path=None, params=None, headers=None, data='', host=None)
+ request = conn.build_base_http_request(
+ method='POST', path='/', auth_path=None, params=None, headers=None,
+ data='', host=None)
conn.set_host_header(request)
self.assertEqual(request.headers['Host'], 'testhost:8773')
+
class V4AuthConnection(AWSAuthConnection):
def __init__(self, host, aws_access_key_id, aws_secret_access_key, port=443):
- AWSAuthConnection.__init__(self, host, aws_access_key_id,
- aws_secret_access_key, port=port)
+ AWSAuthConnection.__init__(
+ self, host, aws_access_key_id, aws_secret_access_key, port=port)
def _required_auth_capability(self):
return ['hmac-v4']
@@ -209,15 +214,17 @@ class V4AuthConnection(AWSAuthConnection):
class TestAWSQueryConnection(unittest.TestCase):
def setUp(self):
- self.region = RegionInfo(name='cc-zone-1',
- endpoint='mockservice.cc-zone-1.amazonaws.com',
- connection_cls=MockAWSService)
+ self.region = RegionInfo(
+ name='cc-zone-1',
+ endpoint='mockservice.cc-zone-1.amazonaws.com',
+ connection_cls=MockAWSService)
HTTPretty.enable()
def tearDown(self):
HTTPretty.disable()
+
class TestAWSQueryConnectionSimple(TestAWSQueryConnection):
def test_query_connection_basis(self):
HTTPretty.register_uri(HTTPretty.POST,
@@ -263,7 +270,7 @@ class TestAWSQueryConnectionSimple(TestAWSQueryConnection):
aws_secret_access_key='secret',
proxy="NON_EXISTENT_HOSTNAME",
proxy_port="3128",
- is_secure = False)
+ is_secure=False)
resp = conn.make_request('myCmd',
{'par1': 'foo', 'par2': 'baz'},
@@ -453,7 +460,7 @@ class TestAWSQueryStatus(TestAWSQueryConnection):
content_type='text/xml')
conn = self.region.connect(aws_access_key_id='access_key',
- aws_secret_access_key='secret')
+ aws_secret_access_key='secret')
with self.assertRaises(BotoServerError):
resp = conn.get_status('getStatus',
{'par1': 'foo', 'par2': 'baz'},
diff --git a/tests/unit/test_exception.py b/tests/unit/test_exception.py
index a14f0dca..d9a2bdd3 100644
--- a/tests/unit/test_exception.py
+++ b/tests/unit/test_exception.py
@@ -4,6 +4,7 @@ from boto.exception import BotoServerError, S3CreateError, JSONResponseError
from httpretty import HTTPretty, httprettified
+
class TestBotoServerError(unittest.TestCase):
def test_botoservererror_basics(self):
@@ -45,7 +46,8 @@ class TestBotoServerError(unittest.TestCase):
<RequestID>e73bb2bb-63e3-9cdc-f220-6332de66dbbe</RequestID>
</Response>"""
bse = BotoServerError('403', 'Forbidden', body=xml)
- self.assertEqual(bse.error_message,
+ self.assertEqual(
+ bse.error_message,
'Session does not have permission to perform (sdb:CreateDomain) on '
'resource (arn:aws:sdb:us-east-1:xxxxxxx:domain/test_domain). '
'Contact account owner.')
@@ -84,18 +86,19 @@ class TestBotoServerError(unittest.TestCase):
self.assertEqual(s3ce.error_code, 'BucketAlreadyOwnedByYou')
self.assertEqual(s3ce.status, '409')
self.assertEqual(s3ce.reason, 'Conflict')
- self.assertEqual(s3ce.error_message,
- 'Your previous request to create the named bucket succeeded '
- 'and you already own it.')
+ self.assertEqual(
+ s3ce.error_message,
+ 'Your previous request to create the named bucket succeeded '
+ 'and you already own it.')
self.assertEqual(s3ce.error_message, s3ce.message)
self.assertEqual(s3ce.request_id, 'FF8B86A32CC3FE4F')
def test_message_json_response_error(self):
# This test comes from https://forums.aws.amazon.com/thread.jspa?messageID=374936
body = {
- '__type': 'com.amazon.coral.validate#ValidationException',
- 'message': 'The attempted filter operation is not supported '
- 'for the provided filter argument count'}
+ '__type': 'com.amazon.coral.validate#ValidationException',
+ 'message': 'The attempted filter operation is not supported '
+ 'for the provided filter argument count'}
jre = JSONResponseError('400', 'Bad Request', body=body)
diff --git a/tests/unit/test_regioninfo.py b/tests/unit/test_regioninfo.py
index 0f492788..c46614d4 100644
--- a/tests/unit/test_regioninfo.py
+++ b/tests/unit/test_regioninfo.py
@@ -23,8 +23,6 @@ import os
from tests.unit import unittest
import boto
-from boto.compat import json
-from boto.exception import BotoServerError
from boto.regioninfo import RegionInfo, load_endpoint_json, merge_endpoints
from boto.regioninfo import load_regions, get_regions