Merge "Return a ClientSideError if unable to convert data"
This commit is contained in:
@@ -119,3 +119,7 @@ class AuthorsController(RestController):
|
||||
@wsmeext.pecan.wsexpose(None, int)
|
||||
def delete(self, author_id):
|
||||
print("Deleting", author_id)
|
||||
|
||||
@wsmeext.pecan.wsexpose(Book, int, body=Author)
|
||||
def put(self, author_id, author=None):
|
||||
return author
|
||||
|
||||
@@ -69,6 +69,19 @@ class TestWS(FunctionalTest):
|
||||
assert a['id'] == 10
|
||||
assert a['firstname'] == 'test'
|
||||
|
||||
def test_put_parameter_validate(self):
|
||||
res = self.app.put(
|
||||
'/authors/foobar', '{"firstname": "test"}',
|
||||
headers={"Content-Type": "application/json"},
|
||||
expect_errors=True
|
||||
)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
a = json.loads(res.body.decode('utf-8'))
|
||||
self.assertEqual(
|
||||
a['faultstring'],
|
||||
"Invalid input for field/attribute author_id. "
|
||||
"Value: 'foobar'. unable to convert to int")
|
||||
|
||||
def test_clientsideerror(self):
|
||||
expected_status_code = 400
|
||||
expected_status = http_response_messages[expected_status_code]
|
||||
|
||||
Reference in New Issue
Block a user