diff --git a/tests/pecantest/test/controllers/ws.py b/tests/pecantest/test/controllers/ws.py index 15f5367..410bbef 100644 --- a/tests/pecantest/test/controllers/ws.py +++ b/tests/pecantest/test/controllers/ws.py @@ -41,9 +41,21 @@ class AuthorsController(RestController): books = BooksController() + @wsme.pecan.wsexpose([Author]) + def get_all(self): + return [ + Author(id=1, firstname=u'FirstName') + ] + @wsme.pecan.wsexpose(Author, int) def get(self, id): author = Author() author.id = id - author.name = u"aname" + author.firstname = u"aname" + author.books = [ + Book( + name=u"Les Confessions d’un révolutionnaire pour servir à " + u"l’histoire de la révolution de février", + ) + ] return author diff --git a/tests/pecantest/test/tests/test_ws.py b/tests/pecantest/test/tests/test_ws.py index 4b7f7d1..03457e9 100644 --- a/tests/pecantest/test/tests/test_ws.py +++ b/tests/pecantest/test/tests/test_ws.py @@ -4,6 +4,9 @@ import json class TestWS(FunctionalTest): + def test_get_all(self): + self.app.get('/authors') + def test_get_author(self): a = self.app.get( '/authors/1.json', @@ -13,9 +16,11 @@ class TestWS(FunctionalTest): print a assert a['id'] == 1 + assert a['firstname'] == 'aname' a = self.app.get( '/authors/1.xml', ) print a assert '1' in a.body + assert 'aname' in a.body diff --git a/wsme/pecan.py b/wsme/pecan.py index ce1341d..f0ad4e5 100644 --- a/wsme/pecan.py +++ b/wsme/pecan.py @@ -49,6 +49,7 @@ def wsexpose(*args, **kwargs): def decorate(f): sig(f) funcdef = wsme.api.FunctionDefinition.get(f) + funcdef.resolve_types(wsme.types.registry) def callfunction(self, *args, **kwargs): args, kwargs = wsme.rest.args.get_args(