Pecan adapter is now at 100% of code coverage

This commit is contained in:
Christophe de Vienne 2013-01-17 12:01:55 +01:00
parent 98a89b808b
commit bd184770a3
2 changed files with 20 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from pecan import expose from pecan import expose
from webob.exc import status_map from webob.exc import status_map
from .ws import AuthorsController from .ws import AuthorsController
from wsme.pecan import wsexpose
class RootController(object): class RootController(object):
@ -14,3 +15,7 @@ class RootController(object):
status = 500 status = 500
message = getattr(status_map.get(status), 'explanation', '') message = getattr(status_map.get(status), 'explanation', '')
return dict(status=status, message=message) return dict(status=status, message=message)
@wsexpose()
def divide_by_zero(self):
1 / 0

View File

@ -67,3 +67,18 @@ class TestWS(FunctionalTest):
a = json.loads(res.body) a = json.loads(res.body)
print a print a
assert a['faultcode'] == 'Client' assert a['faultcode'] == 'Client'
res = self.app.get(
'/authors/999.xml',
expect_errors=True
)
print res
self.assertEqual(res.status, '400 Bad Request')
assert '<faultcode>Client</faultcode>' in res.body
def test_serversideerror(self):
res = self.app.get('/divide_by_zero.json', expect_errors=True)
self.assertEqual(res.status, '500 Internal Server Error')
a = json.loads(res.body)
print a
assert a['faultcode'] == 'Server'