Skip to content

Commit

Permalink
Pep8 Compliance per TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjamenMeyer committed Feb 11, 2015
1 parent 8d8fd5f commit 75178a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
8 changes: 6 additions & 2 deletions stackinabox/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def request(self, method, request, uri, headers):
'removing for match operation.'
.format(self.__id, self.name))
uri_path, uri_qs = uri.split('?')
logger.debug('StackInABoxService ({0}:{1}): uri = "{2}", query = "{3}"'
logger.debug('StackInABoxService ({0}:{1}): uri = "{2}", '
'query = "{3}"'
.format(self.__id, self.name, uri_path, uri_qs))

for k, v in self.routes.items():
Expand All @@ -104,7 +105,10 @@ def request(self, method, request, uri, headers):
if method in v['handlers']:
logger.debug('StackInABoxService ({0}:{1}): Calling '
'handler for route {2} on method {3}...'
.format(self.__id, self.name, v['uri'], method))
.format(self.__id,
self.name,
v['uri'],
method))
return v['handlers'][method](self,
request,
uri,
Expand Down
24 changes: 16 additions & 8 deletions stackinabox/test/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class AdvancedService(StackInABoxService):

def __init__(self):
super(AdvancedService, self).__init__('advanced')
self.register(StackInABoxService.GET, '/', AdvancedService.handler)
self.register(StackInABoxService.GET, '/h', AdvancedService.alternate_handler)
self.register(StackInABoxService.GET, '/g', AdvancedService.query_handler)
self.register(StackInABoxService.GET, '/',
AdvancedService.handler)
self.register(StackInABoxService.GET, '/h',
AdvancedService.alternate_handler)
self.register(StackInABoxService.GET, '/g',
AdvancedService.query_handler)

def handler(self, request, uri, headers):
return (200, headers, 'Hello')
Expand Down Expand Up @@ -79,17 +82,20 @@ def test_basic(self):
'alice': 'alice: Good-Bye bob',
'joe': 'joe: Good-Bye jane'
}
res = requests.get('http://localhost/advanced/g?bob=alice;alice=bob&joe=jane')
res = requests.get('http://localhost/advanced/g?bob=alice;'
'alice=bob&joe=jane')
self.assertEqual(res.status_code, 200)
self.assertEqual(res.json(), expected_result)


def tb_responses_setup():
StackInABox.register_service(AdvancedService())


def tb_responses_teardown():
StackInABox.reset_services()


@responses.activate
def tb_basic_responses():
stackinabox.util_responses.responses_registration('localhost')
Expand All @@ -107,10 +113,12 @@ def tb_basic_responses():
'alice': 'alice: Good-Bye bob',
'joe': 'joe: Good-Bye jane'
}
res = requests.get('http://localhost/advanced/g?bob=alice;alice=bob&joe=jane')
res = requests.get('http://localhost/advanced/g?bob=alice;'
'alice=bob&joe=jane')
assert res.status_code == 200
assert res.json() == expected_result

test_basic_responses = unittest.FunctionTestCase(tb_basic_responses,
setUp=tb_responses_setup,
tearDown=tb_responses_teardown)
test_basic_responses = \
unittest.FunctionTestCase(tb_basic_responses,
setUp=tb_responses_setup,
tearDown=tb_responses_teardown)

0 comments on commit 75178a8

Please sign in to comment.