spore.getdesc does not take a request anymore but only the host url (it makes the tests simplier)
This commit is contained in:
parent
9d03f6f1f1
commit
be16f84738
@ -205,7 +205,7 @@ class WSRoot(object):
|
||||
res_content_type = None
|
||||
|
||||
if request.path == self._webpath + '/api.spore':
|
||||
res.body = spore.getdesc(self, request)
|
||||
res.body = spore.getdesc(self, request.host_url)
|
||||
res.content_type = 'application/json'
|
||||
return res
|
||||
|
||||
|
@ -6,7 +6,7 @@ except ImportError:
|
||||
import json
|
||||
|
||||
|
||||
def getdesc(root, request):
|
||||
def getdesc(root, host_url=''):
|
||||
methods = {}
|
||||
|
||||
for path, funcdef in root.getapi():
|
||||
@ -50,7 +50,7 @@ def getdesc(root, request):
|
||||
formats.append('json')
|
||||
|
||||
api = {
|
||||
'base_url': request.host_url + root._webpath,
|
||||
'base_url': host_url + root._webpath,
|
||||
'version': '0.1',
|
||||
'name': getattr(root, 'name', 'name'),
|
||||
'authority': '',
|
||||
|
@ -21,31 +21,31 @@ class TestSpore(unittest.TestCase):
|
||||
assert len(spore['methods']) == 40, str(len(spore['methods']))
|
||||
|
||||
m = spore['methods']['argtypes_setbytesarray']
|
||||
assert m['path'] == '/argtypes/setbytesarray'
|
||||
assert m['path'] == 'argtypes/setbytesarray', m['path']
|
||||
assert m['optional_params'] == ['value']
|
||||
assert m['method'] == 'POST'
|
||||
|
||||
m = spore['methods']['argtypes_setdecimal']
|
||||
assert m['path'] == '/argtypes/setdecimal'
|
||||
assert m['path'] == 'argtypes/setdecimal'
|
||||
assert m['required_params'] == ['value']
|
||||
assert m['method'] == 'GET'
|
||||
|
||||
m = spore['methods']['crud_create']
|
||||
assert m['path'] == '/crud'
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'PUT'
|
||||
assert m['optional_params'] == ['data']
|
||||
|
||||
m = spore['methods']['crud_read']
|
||||
assert m['path'] == '/crud'
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'GET'
|
||||
assert m['required_params'] == ['ref']
|
||||
|
||||
m = spore['methods']['crud_update']
|
||||
assert m['path'] == '/crud'
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'POST'
|
||||
assert m['optional_params'] == ['data']
|
||||
|
||||
m = spore['methods']['crud_delete']
|
||||
assert m['path'] == '/crud'
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'DELETE'
|
||||
assert m['optional_params'] == ['ref']
|
||||
|
Loading…
Reference in New Issue
Block a user