Add a test for client-side errors

This commit is contained in:
Christophe de Vienne 2012-12-06 16:52:21 +01:00
parent 4edbd4bb8f
commit 38f5dd2bfd
2 changed files with 13 additions and 0 deletions

View File

@ -49,6 +49,8 @@ class AuthorsController(RestController):
@wsme.pecan.wsexpose(Author, int) @wsme.pecan.wsexpose(Author, int)
def get(self, id): def get(self, id):
if id == 999:
raise wsme.exc.ClientSideError('Wrong ID')
author = Author() author = Author()
author.id = id author.id = id
author.firstname = u"aname" author.firstname = u"aname"

View File

@ -24,3 +24,14 @@ class TestWS(FunctionalTest):
print a print a
assert '<id>1</id>' in a.body assert '<id>1</id>' in a.body
assert '<firstname>aname</firstname>' in a.body assert '<firstname>aname</firstname>' in a.body
def test_clientsideerror(self):
res = self.app.get(
'/authors/999.json',
expect_errors=True
)
print res
assert res.status == 400
a = json.loads(res.body)
print a
assert a['faultcode'] == 'Client'