From bcbec29653ebbb40fd13a49aabcf306a2d227535 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Tue, 26 Feb 2013 00:12:34 -0500 Subject: [PATCH] start pep8 cleanup --- moto/core/__init__.py | 2 +- moto/packages/httpretty.py | 2 -- moto/ses/models.py | 2 -- moto/ses/responses.py | 22 +--------------------- moto/sqs/responses.py | 30 ++++-------------------------- setup.py | 6 +++--- tests/test_sqs/test_sqs.py | 1 - 7 files changed, 9 insertions(+), 56 deletions(-) diff --git a/moto/core/__init__.py b/moto/core/__init__.py index a4f19aed..4bf815e7 100644 --- a/moto/core/__init__.py +++ b/moto/core/__init__.py @@ -1 +1 @@ -from .models import BaseBackend \ No newline at end of file +from .models import BaseBackend diff --git a/moto/packages/httpretty.py b/moto/packages/httpretty.py index 6b3bc137..8074f9b5 100644 --- a/moto/packages/httpretty.py +++ b/moto/packages/httpretty.py @@ -247,7 +247,6 @@ class fakesock(object): return self.fd def _true_sendall(self, data, *args, **kw): - import pdb;pdb.set_trace() self.truesock.connect(self._address) self.truesock.sendall(data, *args, **kw) _d = self.truesock.recv(16) @@ -266,7 +265,6 @@ class fakesock(object): hostnames = [getattr(i.info, 'hostname', None) for i in HTTPretty._entries.keys()] self.fd.seek(0) try: - #print("data", data) requestline, _ = data.split('\r\n', 1) method, path, version = parse_requestline(requestline) is_parsing_headers = True diff --git a/moto/ses/models.py b/moto/ses/models.py index 546ff5b7..5c764d76 100644 --- a/moto/ses/models.py +++ b/moto/ses/models.py @@ -1,5 +1,3 @@ -import md5 - from moto.core import BaseBackend from .utils import get_random_message_id diff --git a/moto/ses/responses.py b/moto/ses/responses.py index 8ea3a7e7..5002f925 100644 --- a/moto/ses/responses.py +++ b/moto/ses/responses.py @@ -1,29 +1,9 @@ -import re -from urlparse import parse_qs - from jinja2 import Template -from moto.core.utils import headers_to_dict, camelcase_to_underscores, method_names_from_class +from moto.core.responses import BaseResponse from .models import ses_backend -class BaseResponse(object): - def dispatch(self, uri, body, headers): - querystring = parse_qs(body) - - self.path = uri.path - self.querystring = querystring - - action = querystring['Action'][0] - action = camelcase_to_underscores(action) - - method_names = method_names_from_class(self.__class__) - if action in method_names: - method = getattr(self, action) - return method() - raise NotImplementedError("The {} action has not been implemented".format(action)) - - class EmailResponse(BaseResponse): def verify_email_identity(self): diff --git a/moto/sqs/responses.py b/moto/sqs/responses.py index 82d2b74c..8147dd4c 100644 --- a/moto/sqs/responses.py +++ b/moto/sqs/responses.py @@ -1,32 +1,10 @@ -import re -from urlparse import parse_qs - from jinja2 import Template -from moto.core.utils import headers_to_dict, camelcase_to_underscores, method_names_from_class +from moto.core.responses import BaseResponse +from moto.core.utils import camelcase_to_underscores from .models import sqs_backend -class BaseResponse(object): - def dispatch(self, uri, body, headers): - if body: - querystring = parse_qs(body) - else: - querystring = headers_to_dict(headers) - - self.path = uri.path - self.querystring = querystring - - action = querystring['Action'][0] - action = camelcase_to_underscores(action) - - method_names = method_names_from_class(self.__class__) - if action in method_names: - method = getattr(self, action) - return method() - raise NotImplementedError("The {} action has not been implemented".format(action)) - - class QueuesResponse(BaseResponse): def create_queue(self): @@ -56,7 +34,7 @@ class QueueResponse(BaseResponse): queue_name = self.path.split("/")[-1] key = camelcase_to_underscores(self.querystring.get('Attribute.Name')[0]) value = self.querystring.get('Attribute.Value')[0] - queue = sqs_backend.set_queue_attribute(queue_name, key, value) + sqs_backend.set_queue_attribute(queue_name, key, value) return SET_QUEUE_ATTRIBUTE_RESPONSE def delete_queue(self): @@ -136,7 +114,7 @@ class QueueResponse(BaseResponse): # Found all messages break - message = sqs_backend.delete_message(queue_name, receipt_handle[0]) + sqs_backend.delete_message(queue_name, receipt_handle[0]) message_user_id_key = 'DeleteMessageBatchRequestEntry.{}.Id'.format(index) message_user_id = self.querystring.get(message_user_id_key)[0] diff --git a/setup.py b/setup.py index cfb1dd60..e6756536 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ #!/usr/bin/env python -import sys from setuptools import setup, find_packages setup( name='moto', version='0.0.2', - description='Moto is a library that allows your python tests to easily mock out the boto library', + description='Moto is a library that allows your python tests to easily mock' + ' out the boto library', author='Steve Pulec', author_email='spulec@gmail', url='https://github.com/spulec/moto', @@ -14,4 +14,4 @@ setup( install_requires=[ "boto" ], -) \ No newline at end of file +) diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index 4d1fd24f..edf61f11 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -1,6 +1,5 @@ import boto from boto.exception import SQSError -import requests from sure import expect