diff options
| author | Benoit C | 2012-01-10 00:23:19 +0100 |
|---|---|---|
| committer | Benoit C | 2012-01-10 00:23:19 +0100 |
| commit | 96e91f5841c171a1bcf7571a053ab19de16f402f (patch) | |
| tree | 67e999759b025682d3f732f471a1ebdbec1f6a29 /djangorestframework/tests/views.py | |
| parent | 4ab67e789e78bb5579545d8e0df2389994a72391 (diff) | |
| download | django-rest-framework-96e91f5841c171a1bcf7571a053ab19de16f402f.tar.bz2 | |
Add test for final() method
Diffstat (limited to 'djangorestframework/tests/views.py')
| -rw-r--r-- | djangorestframework/tests/views.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/djangorestframework/tests/views.py b/djangorestframework/tests/views.py index e03f6615..ab5d75d6 100644 --- a/djangorestframework/tests/views.py +++ b/djangorestframework/tests/views.py @@ -1,4 +1,5 @@ from django.conf.urls.defaults import patterns, url +from django.http import HttpResponse from django.test import TestCase from django.test import Client from django import forms @@ -16,6 +17,13 @@ class MockView(View): """This is a basic mock view""" pass + +class MockViewFinal(View): + """View with final() override""" + + def final(self, request, response, *args, **kwargs): + return HttpResponse('{"test": "passed"}', content_type="application/json") + class ResourceMockView(View): """This is a resource-based mock view""" @@ -43,6 +51,7 @@ urlpatterns = patterns('djangorestframework.utils.staticviews', url(r'^accounts/login$', 'api_login'), url(r'^accounts/logout$', 'api_logout'), url(r'^mock/$', MockView.as_view()), + url(r'^mock/final/$', MockViewFinal.as_view()), url(r'^resourcemock/$', ResourceMockView.as_view()), url(r'^model/$', ListOrCreateModelView.as_view(resource=MockResource)), url(r'^model/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=MockResource)), @@ -52,6 +61,13 @@ class BaseViewTests(TestCase): """Test the base view class of djangorestframework""" urls = 'djangorestframework.tests.views' + def test_view_call_final(self): + response = self.client.options('/mock/final/') + self.assertEqual(response['Content-Type'].split(';')[0], "application/json") + parser = JSONParser(None) + (data, files) = parser.parse(StringIO(response.content)) + self.assertEqual(data['test'], 'passed') + def test_options_method_simple_view(self): response = self.client.options('/mock/') self._verify_options_response(response, |
