Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
dad1fa57
Commit
dad1fa57
authored
Apr 11, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
method overloading tests passing
parent
0fe8d1a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
35 deletions
+28
-35
djangorestframework/tests/content.py
+4
-6
djangorestframework/tests/methods.py
+24
-29
No files found.
djangorestframework/tests/content.py
View file @
dad1fa57
# TODO:
refactor these tests
# TODO:
finish off the refactoring
from
django.test
import
TestCase
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.request
import
RequestMixin
from
djangorestframework.parsers
import
FormParser
,
MultipartParser
,
PlainTextParser
#from djangorestframework.content import ContentMixin, StandardContentMixin, OverloadedContentMixin
#
#
class
TestContentMixins
(
TestCase
):
class
TestContentParsing
(
TestCase
):
def
setUp
(
self
):
self
.
req
=
RequestFactory
()
...
...
@@ -125,4 +124,3 @@ class TestContentMixins(TestCase):
# content = 'qwerty'
# request = self.req.post('/', {OverloadedContentMixin.CONTENT_PARAM: content})
# self.assertEqual(OverloadedContentMixin().determine_content(request), (None, content))
djangorestframework/tests/methods.py
View file @
dad1fa57
# TODO: Refactor these tests
#from django.test import TestCase
#from djangorestframework.compat import RequestFactory
from
django.test
import
TestCase
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.request
import
RequestMixin
#from djangorestframework.methods import MethodMixin, StandardMethodMixin, OverloadedPOSTMethodMixin
#
#
#class TestMethodMixins
(TestCase):
#
def setUp(self):
#
self.req = RequestFactory()
class
TestMethodOverloading
(
TestCase
):
def
setUp
(
self
):
self
.
req
=
RequestFactory
()
#
# # Interface tests
#
...
...
@@ -27,27 +28,21 @@
#
# # Behavioural tests
#
# def test_standard_behaviour_determines_GET(self):
# """GET requests identified as GET method with StandardMethodMixin"""
# request = self.req.get('/')
# self.assertEqual(StandardMethodMixin().determine_method(request), 'GET')
#
# def test_standard_behaviour_determines_POST(self):
# """POST requests identified as POST method with StandardMethodMixin"""
# request = self.req.post('/')
# self.assertEqual(StandardMethodMixin().determine_method(request), 'POST')
#
# def test_overloaded_POST_behaviour_determines_GET(self):
# """GET requests identified as GET method with OverloadedPOSTMethodMixin"""
# request = self.req.get('/')
# self.assertEqual(OverloadedPOSTMethodMixin().determine_method(request), 'GET')
#
# def test_overloaded_POST_behaviour_determines_POST(self):
# """POST requests identified as POST method with OverloadedPOSTMethodMixin"""
# request = self.req.post('/')
# 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')
def
test_standard_behaviour_determines_GET
(
self
):
"""GET requests identified"""
view
=
RequestMixin
()
view
.
request
=
self
.
req
.
get
(
'/'
)
self
.
assertEqual
(
view
.
method
,
'GET'
)
def
test_standard_behaviour_determines_POST
(
self
):
"""POST requests identified"""
view
=
RequestMixin
()
view
.
request
=
self
.
req
.
post
(
'/'
)
self
.
assertEqual
(
view
.
method
,
'POST'
)
def
test_overloaded_POST_behaviour_determines_overloaded_method
(
self
):
"""POST requests can be overloaded to another method by setting a reserved form field"""
view
=
RequestMixin
()
view
.
request
=
self
.
req
.
post
(
'/'
,
{
view
.
METHOD_PARAM
:
'DELETE'
})
view
.
perform_form_overloading
()
self
.
assertEqual
(
view
.
method
,
'DELETE'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment