Skip to content

Commit

Permalink
Fix tests for py33.
Browse files Browse the repository at this point in the history
  • Loading branch information
pingviini committed Jan 10, 2014
1 parent 47658df commit 33713b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/whiskers/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def test_get_root(self):
def add_package_data(self):
res = self.app.post_json('/', dict(data=test_data))
self.assertEqual(res.status_int, 200)
self.assertEqual("Added buildout information to Whiskers.",
res.body)
self.assertEqual(res.body.decode(),
u"Added buildout information to Whiskers.")

def test_no_packages_view(self):
res = self.app.get('/packages')
Expand All @@ -31,4 +31,3 @@ def test_package_detailed_view(self):
res = self.app.get('/packages/1')
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, 'text/html')

12 changes: 5 additions & 7 deletions src/whiskers/tests/test_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def test_get_root(self):
def test_post_root(self):
res = self.app.post_json('/', dict(data=test_data))
self.assertEqual(res.status_int, 200)
self.assertEqual("Added buildout information to Whiskers.",
res.body)
self.assertEqual(res.body.decode(),
u"Added buildout information to Whiskers.")

from whiskers.models import (Package, Host)
self.assertEqual(self.session.query(Package).count(), 10)
Expand All @@ -21,13 +21,11 @@ def test_post_root(self):
def test_post_root_with_no_data(self):
res = self.app.post_json('/', dict())
self.assertEqual(res.status_int, 200)
self.assertEqual(res.body, 'No data. Nothing added.')
self.assertEqual(res.body.decode(), u'No data. Nothing added.')

def test_post_root_with_garbled_data(self):
data = '{][}'
res = self.app.post_json('/', dict(data=data))
self.assertEqual(res.status_int, 200)
self.assertEqual(
res.body,
"Not a valid request. Error was: 'unicode' object has no attribute 'get'"
)
self.assertTrue(
u"Not a valid request. Error was: " in res.body.decode())
8 changes: 4 additions & 4 deletions src/whiskers/views/buildouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def post(self):
logging.info("New checksum")
jsondata = JsonDataWrapper(data)
except KeyError:
return Response('No data. Nothing added.')
return Response(u"No data. Nothing added.")
except AttributeError as e:
return Response("Not a valid request. Error was: {error}".format(
return Response(u"Not a valid request. Error was: {error}".format(
error=str(e)))
except Exception as e:
return Response("Adding information failed. Error was: {error}".
return Response(u"Adding information failed. Error was: {error}".
format(error=str(e)))

host = Host.get_by_name(jsondata.hostname)
Expand All @@ -74,7 +74,7 @@ def post(self):

self.add_buildout(jsondata, host, checksum)

return Response('Added buildout information to Whiskers.')
return Response(u'Added buildout information to Whiskers.')

def add_buildout(self, data, host, checksum):
packages = []
Expand Down

0 comments on commit 33713b6

Please sign in to comment.