From fb6a5713af30a9ba945ef83dd408fe84ce924447 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Fri, 11 Jan 2013 12:47:47 -0500 Subject: [PATCH 1/2] Fix a routing-related bug in RestController. fixes #156 --- pecan/core.py | 2 +- pecan/tests/test_rest.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pecan/core.py b/pecan/core.py index fb741a9..fda40b7 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -307,7 +307,7 @@ class Pecan(object): valid_args = valid_args[len(args):] # handle wildcard arguments - if remainder: + if filter(None, remainder): if not argspec[1]: abort(404) args.extend(remainder) diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py index 4935c00..1bad77f 100644 --- a/pecan/tests/test_rest.py +++ b/pecan/tests/test_rest.py @@ -863,3 +863,27 @@ class TestRestController(TestCase): r = app.get('/foos/bars/bazs/final/named') assert r.status_int == 200 assert r.body == 'NAMED' + + def test_post_with_kwargs_only(self): + + class RootController(RestController): + + @expose() + def get_all(self): + return 'INDEX' + + @expose('json') + def post(self, **kw): + return kw + + # create the app + app = TestApp(make_app(RootController())) + + r = app.get('/') + assert r.status_int == 200 + assert r.body == 'INDEX' + + kwargs = {'foo': 'bar', 'spam': 'eggs'} + r = app.post('/', kwargs) + assert r.status_int == 200 + assert r.body == dumps(kwargs) From 3a9cb397038897fd5e515769b84d510be8ee301d Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Fri, 18 Jan 2013 15:32:36 -0500 Subject: [PATCH 2/2] Update a test to be more repeatable. --- pecan/tests/test_rest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py index 1bad77f..ce855ee 100644 --- a/pecan/tests/test_rest.py +++ b/pecan/tests/test_rest.py @@ -886,4 +886,5 @@ class TestRestController(TestCase): kwargs = {'foo': 'bar', 'spam': 'eggs'} r = app.post('/', kwargs) assert r.status_int == 200 - assert r.body == dumps(kwargs) + assert r.namespace['foo'] == 'bar' + assert r.namespace['spam'] == 'eggs'