diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-02-18 09:50:03 +0000 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-02-18 09:50:03 +0000 |
| commit | 52b06e29c76dc9a5184edf3bbea64f0d4d5442b1 (patch) | |
| tree | 2d58788d532d01cbae6cf4eaccaf50fc8535c705 /tests | |
| parent | 8d221e554c0d47256f02d42f1b86909a67c86ed3 (diff) | |
Prevented the generic views from automatically creating a HEAD method when there is no GET. Reverts r16105, refs #17449.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17545 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/generic_views/base.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py index d9debb6627..e7aeaf9cde 100644 --- a/tests/regressiontests/generic_views/base.py +++ b/tests/regressiontests/generic_views/base.py @@ -19,9 +19,15 @@ class SimplePostView(SimpleView): post = SimpleView.get +class PostOnlyView(View): + def post(self, request): + return HttpResponse('This view only accepts POST') + + class CustomizableView(SimpleView): parameter = {} + def decorator(view): view.is_decorated = True return view @@ -102,12 +108,19 @@ class ViewTest(unittest.TestCase): def test_get_and_head(self): """ - Test a view which supplies a GET method also responds correctly to HEAD + Test a view which supplies a GET method also responds correctly to HEAD. """ self._assert_simple(SimpleView.as_view()(self.rf.get('/'))) response = SimpleView.as_view()(self.rf.head('/')) self.assertEqual(response.status_code, 200) + def test_head_no_get(self): + """ + Test a view which supplies no GET method responds to HEAD with HTTP 405. + """ + response = PostOnlyView.as_view()(self.rf.head('/')) + self.assertEqual(response.status_code, 405) + def test_get_and_post(self): """ Test a view which only allows both GET and POST. |
