summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-06-19 21:43:46 -0400
committerChris McDonough <chrism@plope.com>2011-06-19 21:43:46 -0400
commit4275ebb943e5549ceb51577b2e5b1ae7a3ee5b20 (patch)
treee8360e8d48644df128a761bd5394a99d8c5f0408
parent366a5ce3f0c7ac1c02b58523721ab7dff2be133f (diff)
downloadpyramid-4275ebb943e5549ceb51577b2e5b1ae7a3ee5b20.tar.gz
pyramid-4275ebb943e5549ceb51577b2e5b1ae7a3ee5b20.tar.bz2
pyramid-4275ebb943e5549ceb51577b2e5b1ae7a3ee5b20.zip
- Copy exception templates from webob.exc into pyramid.httpexceptions and
ensure they all work.
-rw-r--r--TODO.txt3
-rw-r--r--pyramid/tests/test_httpexceptions.py30
2 files changed, 29 insertions, 4 deletions
diff --git a/TODO.txt b/TODO.txt
index f24b49263..adefbc573 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -6,9 +6,6 @@ Must-Have
- Grep for IExceptionResponse, forgot what it does.
-- Copy exception templates from webob.exc into pyramid.httpexceptions and
- ensure they all work.
-
- Docs mention ``exception.args[0]`` as a way to get messages; check that
this works.
diff --git a/pyramid/tests/test_httpexceptions.py b/pyramid/tests/test_httpexceptions.py
index 9ea9c76e4..705b988e6 100644
--- a/pyramid/tests/test_httpexceptions.py
+++ b/pyramid/tests/test_httpexceptions.py
@@ -278,6 +278,19 @@ class Test_HTTPMove(unittest.TestCase):
exc = self._makeOne(location='foo')
self.assertEqual(exc.location, 'foo')
+ def test_it_location_firstarg(self):
+ exc = self._makeOne('foo')
+ self.assertEqual(exc.location, 'foo')
+
+ def test_it_call_with_default_body_tmpl(self):
+ exc = self._makeOne(location='foo')
+ environ = _makeEnviron()
+ start_response = DummyStartResponse()
+ app_iter = exc(environ, start_response)
+ self.assertEqual(app_iter[0],
+ ('None None\n\nThe resource has been moved to foo; '
+ 'you should be redirected automatically.\n\n'))
+
class TestHTTPForbidden(unittest.TestCase):
def _makeOne(self, *arg, **kw):
from pyramid.httpexceptions import HTTPForbidden
@@ -290,7 +303,22 @@ class TestHTTPForbidden(unittest.TestCase):
def test_it_result_passed(self):
exc = self._makeOne(result='foo')
self.assertEqual(exc.result, 'foo')
-
+
+class TestHTTPMethodNotAllowed(unittest.TestCase):
+ def _makeOne(self, *arg, **kw):
+ from pyramid.httpexceptions import HTTPMethodNotAllowed
+ return HTTPMethodNotAllowed(*arg, **kw)
+
+ def test_it_with_default_body_tmpl(self):
+ exc = self._makeOne()
+ environ = _makeEnviron()
+ start_response = DummyStartResponse()
+ app_iter = exc(environ, start_response)
+ self.assertEqual(app_iter[0],
+ ('405 Method Not Allowed\n\nThe method GET is not '
+ 'allowed for this resource. \n\n\n'))
+
+
class DummyRequest(object):
exception = None