From 4275ebb943e5549ceb51577b2e5b1ae7a3ee5b20 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 19 Jun 2011 21:43:46 -0400 Subject: - Copy exception templates from webob.exc into pyramid.httpexceptions and ensure they all work. --- TODO.txt | 3 --- pyramid/tests/test_httpexceptions.py | 30 +++++++++++++++++++++++++++++- 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 -- cgit v1.2.3