diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-01-12 19:59:37 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-01-12 19:59:37 +0000 |
commit | b98aac0abca66b303bd0d1d81d5a5bebd08538a2 (patch) | |
tree | 28ffc00878f199b34352957f73d4f39ec58d9e99 /pecan/tests/test_rest.py | |
parent | 62871d2d348558e87011c4a1f00cb244b90a5d8e (diff) | |
parent | f491076a0f1b9f080c139a8062c9481e8024d8cb (diff) | |
download | pecan-b98aac0abca66b303bd0d1d81d5a5bebd08538a2.tar.gz |
Merge "Change pecan to more gracefully handle a few odd request encoding edge cases."
Diffstat (limited to 'pecan/tests/test_rest.py')
-rw-r--r-- | pecan/tests/test_rest.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py index d839084..391b7d0 100644 --- a/pecan/tests/test_rest.py +++ b/pecan/tests/test_rest.py @@ -1,11 +1,12 @@ -from webtest import TestApp +import struct import warnings try: from simplejson import dumps, loads except: from json import dumps, loads # noqa -from six import b as b_ +from six import b as b_, PY3 +from webtest import TestApp from pecan import abort, expose, make_app, response, redirect from pecan.rest import RestController @@ -1359,6 +1360,27 @@ class TestRestController(PecanTestCase): assert r.status_int == 200 assert r.body == b_("DEFAULT missing") + def test_rest_with_non_utf_8_body(self): + if PY3: + # webob+PY3 doesn't suffer from this bug; the POST parsing in PY3 + # seems to more gracefully detect the bytestring + return + + class FooController(RestController): + + @expose() + def post(self): + return "POST" + + class RootController(RestController): + foo = FooController() + + app = TestApp(make_app(RootController())) + + data = struct.pack('255h', *range(0, 255)) + r = app.post('/foo/', data, expect_errors=True) + assert r.status_int == 400 + def test_dynamic_rest_lookup(self): class BarController(RestController): @expose() |