Add a test for client-side errors
This commit is contained in:
parent
4edbd4bb8f
commit
38f5dd2bfd
@ -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"
|
||||||
|
@ -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'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user