From be16f847380b17aa26629798920db31188b53f0d Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Mon, 24 Sep 2012 22:10:10 +0200 Subject: [PATCH] spore.getdesc does not take a request anymore but only the host url (it makes the tests simplier) --- wsme/root.py | 2 +- wsme/spore.py | 4 ++-- wsme/tests/test_spore.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wsme/root.py b/wsme/root.py index 91a0106..07728d8 100644 --- a/wsme/root.py +++ b/wsme/root.py @@ -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 diff --git a/wsme/spore.py b/wsme/spore.py index e481bf6..9c4d1eb 100644 --- a/wsme/spore.py +++ b/wsme/spore.py @@ -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': '', diff --git a/wsme/tests/test_spore.py b/wsme/tests/test_spore.py index 82a6766..ad2be2e 100644 --- a/wsme/tests/test_spore.py +++ b/wsme/tests/test_spore.py @@ -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']