Add a test for the body= parameter of wsexpose
--HG-- extra : rebase_source : fc9479a0aa0de8485440a70e86971666fea56fb8
This commit is contained in:
parent
5c87210733
commit
9ee2d2f9a2
@ -27,13 +27,16 @@ class BooksController(RestController):
|
|||||||
book = Book(
|
book = Book(
|
||||||
name=u"Les Confessions d’un révolutionnaire pour servir à "
|
name=u"Les Confessions d’un révolutionnaire pour servir à "
|
||||||
u"l’histoire de la révolution de février",
|
u"l’histoire de la révolution de février",
|
||||||
author=Author(lastname=u"Proudhon"))
|
author=Author(lastname=u"Proudhon")
|
||||||
|
)
|
||||||
return book
|
return book
|
||||||
|
|
||||||
@wsmeext.pecan.wsexpose(Book, int, int, body=Book)
|
@wsmeext.pecan.wsexpose(Book, int, int, body=Book)
|
||||||
def put(self, author_id, id, book=None):
|
def put(self, author_id, id, book=None):
|
||||||
print author_id, id
|
print author_id, id
|
||||||
print book
|
print book
|
||||||
|
book.id = id
|
||||||
|
book.author = Author(id=author_id)
|
||||||
return book
|
return book
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,3 +82,14 @@ class TestWS(FunctionalTest):
|
|||||||
a = json.loads(res.body)
|
a = json.loads(res.body)
|
||||||
print a
|
print a
|
||||||
assert a['faultcode'] == 'Server'
|
assert a['faultcode'] == 'Server'
|
||||||
|
|
||||||
|
def test_body_parameter(self):
|
||||||
|
res = self.app.put(
|
||||||
|
'/authors/1/books/2.json',
|
||||||
|
'{"name": "Alice au pays des merveilles"}',
|
||||||
|
headers={"Content-Type": "application/json"}
|
||||||
|
)
|
||||||
|
book = json.loads(res.body)
|
||||||
|
print book
|
||||||
|
assert book['id'] == 2
|
||||||
|
assert book['author']['id'] == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user