From bd184770a3559293c8eb42c3974ea507cb7cf44f Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Thu, 17 Jan 2013 12:01:55 +0100 Subject: [PATCH] Pecan adapter is now at 100% of code coverage --- tests/pecantest/test/controllers/root.py | 5 +++++ tests/pecantest/test/tests/test_ws.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/pecantest/test/controllers/root.py b/tests/pecantest/test/controllers/root.py index b098376..ec067da 100644 --- a/tests/pecantest/test/controllers/root.py +++ b/tests/pecantest/test/controllers/root.py @@ -1,6 +1,7 @@ from pecan import expose from webob.exc import status_map from .ws import AuthorsController +from wsme.pecan import wsexpose class RootController(object): @@ -14,3 +15,7 @@ class RootController(object): status = 500 message = getattr(status_map.get(status), 'explanation', '') return dict(status=status, message=message) + + @wsexpose() + def divide_by_zero(self): + 1 / 0 diff --git a/tests/pecantest/test/tests/test_ws.py b/tests/pecantest/test/tests/test_ws.py index d971eba..2f4f3cb 100644 --- a/tests/pecantest/test/tests/test_ws.py +++ b/tests/pecantest/test/tests/test_ws.py @@ -67,3 +67,18 @@ class TestWS(FunctionalTest): a = json.loads(res.body) print a assert a['faultcode'] == 'Client' + + res = self.app.get( + '/authors/999.xml', + expect_errors=True + ) + print res + self.assertEqual(res.status, '400 Bad Request') + assert 'Client' 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'