From d71b762ae347c1bd0e732d34b03919a44aa15aee Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Fri, 15 Feb 2013 14:33:25 +0100 Subject: [PATCH] Add a test to reproduce the bug reported by Endre Karlson --- tests/pecantest/test/controllers/ws.py | 5 +++++ tests/pecantest/test/tests/test_ws.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/pecantest/test/controllers/ws.py b/tests/pecantest/test/controllers/ws.py index 8a3535e..d85ff55 100644 --- a/tests/pecantest/test/controllers/ws.py +++ b/tests/pecantest/test/controllers/ws.py @@ -80,3 +80,8 @@ class AuthorsController(RestController): ) ] return author + + @wsmeext.pecan.wsexpose(Author, body=Author) + def post(self, author): + author.id = 10 + return author diff --git a/tests/pecantest/test/tests/test_ws.py b/tests/pecantest/test/tests/test_ws.py index 3bb409d..621b672 100644 --- a/tests/pecantest/test/tests/test_ws.py +++ b/tests/pecantest/test/tests/test_ws.py @@ -57,6 +57,16 @@ class TestWS(FunctionalTest): assert '1' in a.body assert 'aname' in a.body + def test_post_body_parameter(self): + res = self.app.post( + '/authors', '{"firstname": "test"}', + headers={"Content-Type": "application/json"} + ) + a = json.loads(res.body) + print a + assert a['id'] == 10 + assert a['firstname'] == 'test' + def test_clientsideerror(self): res = self.app.get( '/authors/999.json',