From d32059f3014ab27c60d3b183fc1b48717fb24fe3 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Tue, 26 Feb 2013 00:31:01 -0500 Subject: [PATCH] pep8 --- moto/dynamodb/models.py | 41 +++++++++++++------------ moto/dynamodb/urls.py | 2 +- moto/dynamodb/utils.py | 1 + moto/ec2/__init__.py | 2 +- moto/ec2/models.py | 8 ++--- moto/ec2/responses/__init__.py | 1 - moto/ec2/responses/amis.py | 1 - moto/s3/__init__.py | 2 +- moto/s3/models.py | 2 +- moto/ses/models.py | 3 +- moto/ses/utils.py | 2 +- moto/sqs/models.py | 1 + moto/sqs/responses.py | 2 +- tests/test_dynamodb/test_dynamodb.py | 42 +++++++++++++------------- tests/test_ec2/test_ec2_core.py | 2 +- tests/test_ec2/test_security_groups.py | 5 +-- 16 files changed, 59 insertions(+), 58 deletions(-) diff --git a/moto/dynamodb/models.py b/moto/dynamodb/models.py index 880e73a8d..fdb5040fd 100644 --- a/moto/dynamodb/models.py +++ b/moto/dynamodb/models.py @@ -20,28 +20,29 @@ class Table(object): @property def describe(self): - return {"Table": { - "CreationDateTime": unix_time(self.created_at), - "KeySchema": { - "HashKeyElement": { - "AttributeName": self.hash_key_attr, - "AttributeType": self.hash_key_type + return { + "Table": { + "CreationDateTime": unix_time(self.created_at), + "KeySchema": { + "HashKeyElement": { + "AttributeName": self.hash_key_attr, + "AttributeType": self.hash_key_type + }, + "RangeKeyElement": { + "AttributeName": self.range_key_attr, + "AttributeType": self.range_key_type + } }, - "RangeKeyElement": { - "AttributeName": self.range_key_attr, - "AttributeType": self.range_key_type - } - }, - "ProvisionedThroughput": { - "ReadCapacityUnits": self.read_capacity, - "WriteCapacityUnits": self.write_capacity - }, - "TableName": self.name, - "TableStatus": "ACTIVE", - "ItemCount": 0, - "TableSizeBytes": 0, + "ProvisionedThroughput": { + "ReadCapacityUnits": self.read_capacity, + "WriteCapacityUnits": self.write_capacity + }, + "TableName": self.name, + "TableStatus": "ACTIVE", + "ItemCount": 0, + "TableSizeBytes": 0, + } } - } class DynamoDBBackend(BaseBackend): diff --git a/moto/dynamodb/urls.py b/moto/dynamodb/urls.py index a42f1ee92..3c6b70963 100644 --- a/moto/dynamodb/urls.py +++ b/moto/dynamodb/urls.py @@ -2,4 +2,4 @@ from .responses import handler urls = { "https://dynamodb.us-east-1.amazonaws.com/": handler, -} \ No newline at end of file +} diff --git a/moto/dynamodb/utils.py b/moto/dynamodb/utils.py index 0c11c10cf..e4787d105 100644 --- a/moto/dynamodb/utils.py +++ b/moto/dynamodb/utils.py @@ -1,5 +1,6 @@ import datetime + def unix_time(dt): epoch = datetime.datetime.utcfromtimestamp(0) delta = dt - epoch diff --git a/moto/ec2/__init__.py b/moto/ec2/__init__.py index f64708fee..089c79df1 100644 --- a/moto/ec2/__init__.py +++ b/moto/ec2/__init__.py @@ -1,2 +1,2 @@ from .models import ec2_backend -mock_ec2 = ec2_backend.decorator \ No newline at end of file +mock_ec2 = ec2_backend.decorator diff --git a/moto/ec2/models.py b/moto/ec2/models.py index a84d6a8fc..9455da630 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -132,6 +132,7 @@ class Ami(object): self.virtualization_type = instance.virtualization_type self.kernel_id = instance.kernel + class AmiBackend(object): def __init__(self): self.amis = {} @@ -143,7 +144,7 @@ class AmiBackend(object): instance = self.get_instance(instance_id) if not instance: return None - ami = Ami(ami_id, instance, name, description) + ami = Ami(ami_id, instance, name, description) self.amis[ami_id] = ami return ami @@ -218,7 +219,7 @@ class SecurityRule(object): self.to_port, self.ip_ranges, self.source_groups - ) + ) def __eq__(self, other): return self.unique_representation == other.unique_representation @@ -244,7 +245,7 @@ class SecurityGroupBackend(object): existing_group = self.get_security_group_from_name(name) if existing_group: return None - group = SecurityGroup(group_id, name, description) + group = SecurityGroup(group_id, name, description) self.groups[group_id] = group return group @@ -381,4 +382,3 @@ class EC2Backend(BaseBackend, InstanceBackend, TagBackend, AmiBackend, RegionsAn ec2_backend = EC2Backend() - diff --git a/moto/ec2/responses/__init__.py b/moto/ec2/responses/__init__.py index ce27693c6..a72698730 100644 --- a/moto/ec2/responses/__init__.py +++ b/moto/ec2/responses/__init__.py @@ -32,7 +32,6 @@ from .vpn_connections import VPNConnections from .windows import Windows - class EC2Response(object): sub_responses = [ diff --git a/moto/ec2/responses/amis.py b/moto/ec2/responses/amis.py index 9113c4a76..24cf9e94b 100644 --- a/moto/ec2/responses/amis.py +++ b/moto/ec2/responses/amis.py @@ -99,4 +99,3 @@ DEREGISTER_IMAGE_RESPONSE = """ d6f86b7a-74d1-4439-b43f-196a1e29cd85 -""" \ No newline at end of file +""" diff --git a/tests/test_dynamodb/test_dynamodb.py b/tests/test_dynamodb/test_dynamodb.py index d23923086..2731718a2 100644 --- a/tests/test_dynamodb/test_dynamodb.py +++ b/tests/test_dynamodb/test_dynamodb.py @@ -27,26 +27,26 @@ def test_describe_table(): ) conn = boto.connect_dynamodb('the_key', 'the_secret') expected = { - 'Table': { - 'CreationDateTime': 1326499200.0, - 'ItemCount': 0, - 'KeySchema': { - 'HashKeyElement': { - 'AttributeName': 'forum_name', - 'AttributeType': 'S' - }, - 'RangeKeyElement': { - 'AttributeName': 'subject', - 'AttributeType': 'S' - } - }, - 'ProvisionedThroughput': { - 'ReadCapacityUnits': 10, - 'WriteCapacityUnits': 10 - }, - 'TableName': 'messages', - 'TableSizeBytes': 0, - 'TableStatus': 'ACTIVE' + 'Table': { + 'CreationDateTime': 1326499200.0, + 'ItemCount': 0, + 'KeySchema': { + 'HashKeyElement': { + 'AttributeName': 'forum_name', + 'AttributeType': 'S' + }, + 'RangeKeyElement': { + 'AttributeName': 'subject', + 'AttributeType': 'S' } - } + }, + 'ProvisionedThroughput': { + 'ReadCapacityUnits': 10, + 'WriteCapacityUnits': 10 + }, + 'TableName': 'messages', + 'TableSizeBytes': 0, + 'TableStatus': 'ACTIVE' + } + } assert conn.describe_table('messages') == expected diff --git a/tests/test_ec2/test_ec2_core.py b/tests/test_ec2/test_ec2_core.py index b698eec79..c07f5c809 100644 --- a/tests/test_ec2/test_ec2_core.py +++ b/tests/test_ec2/test_ec2_core.py @@ -5,4 +5,4 @@ from moto import mock_ec2 @mock_ec2 def test_not_implemented_method(): requests.post.when.called_with("https://ec2.us-east-1.amazonaws.com/", - data={'Action':['foobar']}).should.throw(NotImplementedError) + data={'Action': ['foobar']}).should.throw(NotImplementedError) diff --git a/tests/test_ec2/test_security_groups.py b/tests/test_ec2/test_security_groups.py index eaff802ef..8ed0ed7f6 100644 --- a/tests/test_ec2/test_security_groups.py +++ b/tests/test_ec2/test_security_groups.py @@ -10,7 +10,7 @@ def test_create_and_describe_security_group(): conn = boto.connect_ec2('the_key', 'the_secret') security_group = conn.create_security_group('test security group', 'this is a test security group') - security_group.name.should.equal('test security group') + expect(security_group).name.should.equal('test security group') security_group.description.should.equal('this is a test security group') # Trying to create another group with the same name should throw an error @@ -25,7 +25,7 @@ def test_create_and_describe_security_group(): def test_deleting_security_groups(): conn = boto.connect_ec2('the_key', 'the_secret') security_group1 = conn.create_security_group('test1', 'test1') - security_group2 = conn.create_security_group('test2', 'test2') + conn.create_security_group('test2', 'test2') conn.get_all_security_groups().should.have.length_of(2) @@ -62,6 +62,7 @@ def test_authorize_ip_range_and_revoke(): security_group = conn.get_all_security_groups()[0] security_group.rules.should.have.length_of(0) + @mock_ec2 def test_authorize_other_group_and_revoke(): conn = boto.connect_ec2('the_key', 'the_secret')