method overloading tests passing

This commit is contained in:
Tom Christie 2011-04-11 13:13:25 +01:00
parent 0fe8d1a15d
commit dad1fa5798
2 changed files with 28 additions and 35 deletions

View File

@ -1,12 +1,11 @@
# TODO: refactor these tests # TODO: finish off the refactoring
from django.test import TestCase from django.test import TestCase
from djangorestframework.compat import RequestFactory from djangorestframework.compat import RequestFactory
from djangorestframework.request import RequestMixin from djangorestframework.request import RequestMixin
from djangorestframework.parsers import FormParser, MultipartParser, PlainTextParser from djangorestframework.parsers import FormParser, MultipartParser, PlainTextParser
#from djangorestframework.content import ContentMixin, StandardContentMixin, OverloadedContentMixin
#
# class TestContentParsing(TestCase):
class TestContentMixins(TestCase):
def setUp(self): def setUp(self):
self.req = RequestFactory() self.req = RequestFactory()
@ -125,4 +124,3 @@ class TestContentMixins(TestCase):
# content = 'qwerty' # content = 'qwerty'
# request = self.req.post('/', {OverloadedContentMixin.CONTENT_PARAM: content}) # request = self.req.post('/', {OverloadedContentMixin.CONTENT_PARAM: content})
# self.assertEqual(OverloadedContentMixin().determine_content(request), (None, content)) # self.assertEqual(OverloadedContentMixin().determine_content(request), (None, content))

View File

@ -1,12 +1,13 @@
# TODO: Refactor these tests # TODO: Refactor these tests
#from django.test import TestCase from django.test import TestCase
#from djangorestframework.compat import RequestFactory from djangorestframework.compat import RequestFactory
from djangorestframework.request import RequestMixin
#from djangorestframework.methods import MethodMixin, StandardMethodMixin, OverloadedPOSTMethodMixin #from djangorestframework.methods import MethodMixin, StandardMethodMixin, OverloadedPOSTMethodMixin
# #
# #
#class TestMethodMixins(TestCase): class TestMethodOverloading(TestCase):
# def setUp(self): def setUp(self):
# self.req = RequestFactory() self.req = RequestFactory()
# #
# # Interface tests # # Interface tests
# #
@ -27,27 +28,21 @@
# #
# # Behavioural tests # # Behavioural tests
# #
# def test_standard_behaviour_determines_GET(self): def test_standard_behaviour_determines_GET(self):
# """GET requests identified as GET method with StandardMethodMixin""" """GET requests identified"""
# request = self.req.get('/') view = RequestMixin()
# self.assertEqual(StandardMethodMixin().determine_method(request), 'GET') view.request = self.req.get('/')
# self.assertEqual(view.method, 'GET')
# def test_standard_behaviour_determines_POST(self):
# """POST requests identified as POST method with StandardMethodMixin""" def test_standard_behaviour_determines_POST(self):
# request = self.req.post('/') """POST requests identified"""
# self.assertEqual(StandardMethodMixin().determine_method(request), 'POST') view = RequestMixin()
# view.request = self.req.post('/')
# def test_overloaded_POST_behaviour_determines_GET(self): self.assertEqual(view.method, 'POST')
# """GET requests identified as GET method with OverloadedPOSTMethodMixin"""
# request = self.req.get('/') def test_overloaded_POST_behaviour_determines_overloaded_method(self):
# self.assertEqual(OverloadedPOSTMethodMixin().determine_method(request), 'GET') """POST requests can be overloaded to another method by setting a reserved form field"""
# view = RequestMixin()
# def test_overloaded_POST_behaviour_determines_POST(self): view.request = self.req.post('/', {view.METHOD_PARAM: 'DELETE'})
# """POST requests identified as POST method with OverloadedPOSTMethodMixin""" view.perform_form_overloading()
# request = self.req.post('/') self.assertEqual(view.method, 'DELETE')
# self.assertEqual(OverloadedPOSTMethodMixin().determine_method(request), 'POST')
#
# def test_overloaded_POST_behaviour_determines_overloaded_method(self):
# """POST requests can be overloaded to another method by setting a reserved form field with OverloadedPOSTMethodMixin"""
# request = self.req.post('/', {OverloadedPOSTMethodMixin.METHOD_PARAM: 'DELETE'})
# self.assertEqual(OverloadedPOSTMethodMixin().determine_method(request), 'DELETE')