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(
|
||||
name=u"Les Confessions d’un révolutionnaire pour servir à "
|
||||
u"l’histoire de la révolution de février",
|
||||
author=Author(lastname=u"Proudhon"))
|
||||
author=Author(lastname=u"Proudhon")
|
||||
)
|
||||
return book
|
||||
|
||||
@wsmeext.pecan.wsexpose(Book, int, int, body=Book)
|
||||
def put(self, author_id, id, book=None):
|
||||
print author_id, id
|
||||
print book
|
||||
book.id = id
|
||||
book.author = Author(id=author_id)
|
||||
return book
|
||||
|
||||
|
||||
@ -73,7 +76,7 @@ class AuthorsController(RestController):
|
||||
author.books = [
|
||||
Book(
|
||||
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",
|
||||
)
|
||||
]
|
||||
return author
|
||||
|
@ -82,3 +82,14 @@ class TestWS(FunctionalTest):
|
||||
a = json.loads(res.body)
|
||||
print a
|
||||
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