resolve types in pecan.wsexpose. It is a temporary solution.
--HG-- extra : rebase_source : a6835042f14fb016722323496ba8b826a2a8aa9d
This commit is contained in:
parent
cbb5caf4bf
commit
67bf6c3dc4
@ -41,9 +41,21 @@ class AuthorsController(RestController):
|
|||||||
|
|
||||||
books = BooksController()
|
books = BooksController()
|
||||||
|
|
||||||
|
@wsme.pecan.wsexpose([Author])
|
||||||
|
def get_all(self):
|
||||||
|
return [
|
||||||
|
Author(id=1, firstname=u'FirstName')
|
||||||
|
]
|
||||||
|
|
||||||
@wsme.pecan.wsexpose(Author, int)
|
@wsme.pecan.wsexpose(Author, int)
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
author = Author()
|
author = Author()
|
||||||
author.id = id
|
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
|
return author
|
||||||
|
@ -4,6 +4,9 @@ import json
|
|||||||
|
|
||||||
class TestWS(FunctionalTest):
|
class TestWS(FunctionalTest):
|
||||||
|
|
||||||
|
def test_get_all(self):
|
||||||
|
self.app.get('/authors')
|
||||||
|
|
||||||
def test_get_author(self):
|
def test_get_author(self):
|
||||||
a = self.app.get(
|
a = self.app.get(
|
||||||
'/authors/1.json',
|
'/authors/1.json',
|
||||||
@ -13,9 +16,11 @@ class TestWS(FunctionalTest):
|
|||||||
print a
|
print a
|
||||||
|
|
||||||
assert a['id'] == 1
|
assert a['id'] == 1
|
||||||
|
assert a['firstname'] == 'aname'
|
||||||
|
|
||||||
a = self.app.get(
|
a = self.app.get(
|
||||||
'/authors/1.xml',
|
'/authors/1.xml',
|
||||||
)
|
)
|
||||||
print a
|
print a
|
||||||
assert '<id>1</id>' in a.body
|
assert '<id>1</id>' in a.body
|
||||||
|
assert '<firstname>aname</firstname>' in a.body
|
||||||
|
@ -49,6 +49,7 @@ def wsexpose(*args, **kwargs):
|
|||||||
def decorate(f):
|
def decorate(f):
|
||||||
sig(f)
|
sig(f)
|
||||||
funcdef = wsme.api.FunctionDefinition.get(f)
|
funcdef = wsme.api.FunctionDefinition.get(f)
|
||||||
|
funcdef.resolve_types(wsme.types.registry)
|
||||||
|
|
||||||
def callfunction(self, *args, **kwargs):
|
def callfunction(self, *args, **kwargs):
|
||||||
args, kwargs = wsme.rest.args.get_args(
|
args, kwargs = wsme.rest.args.get_args(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user