summaryrefslogtreecommitdiff
path: root/pecan/tests
diff options
context:
space:
mode:
authorJonathan LaCour <jonathan@cleverdevil.org>2013-03-19 10:59:15 -0700
committerJonathan LaCour <jonathan@cleverdevil.org>2013-03-19 10:59:15 -0700
commita689f9ba435f1e662e0d12ca6743e95f490ca9ab (patch)
treecab01505a8eabaefff79f0e75497553eed2f7078 /pecan/tests
parent7553f19f0af8bd6e41c2f5482945278dc12bc418 (diff)
parent1b92443d5c422e344e9bb6b98d9b07da139365f8 (diff)
downloadpecan-a689f9ba435f1e662e0d12ca6743e95f490ca9ab.tar.gz
Merge pull request #190 from ryanpetrello/bug-nested-delete
Fix a bug in DELETE methods in two (or more) nested RestControllers.
Diffstat (limited to 'pecan/tests')
-rw-r--r--pecan/tests/test_rest.py56
1 files changed, 55 insertions, 1 deletions
diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py
index 4c84d5d..6cd7bba 100644
--- a/pecan/tests/test_rest.py
+++ b/pecan/tests/test_rest.py
@@ -287,7 +287,61 @@ class TestRestController(PecanTestCase):
assert r.status_int == 200
assert r.body == dumps(dict(items=ThingsController.data))
- def test_nested_rest(self):
+ def test_simple_nested_rest(self):
+
+ class BarController(RestController):
+
+ @expose()
+ def post(self):
+ return "BAR-POST"
+
+ @expose()
+ def delete(self, id_):
+ return "BAR-%s" % id_
+
+ @expose()
+ def post(self):
+ return "BAR-POST"
+
+ @expose()
+ def delete(self, id_):
+ return "BAR-%s" % id_
+
+ class FooController(RestController):
+
+ bar = BarController()
+
+ @expose()
+ def post(self):
+ return "FOO-POST"
+
+ @expose()
+ def delete(self, id_):
+ return "FOO-%s" % id_
+
+ class RootController(object):
+ foo = FooController()
+
+ # create the app
+ app = TestApp(make_app(RootController()))
+
+ r = app.post('/foo')
+ assert r.status_int == 200
+ assert r.body == "FOO-POST"
+
+ r = app.delete('/foo/1')
+ assert r.status_int == 200
+ assert r.body == "FOO-1"
+
+ r = app.post('/foo/bar')
+ assert r.status_int == 200
+ assert r.body == "BAR-POST"
+
+ r = app.delete('/foo/bar/2')
+ assert r.status_int == 200
+ assert r.body == "BAR-2"
+
+ def test_complicated_nested_rest(self):
class BarsController(RestController):