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
7a5cd090
Commit
7a5cd090
authored
May 19, 2013
by
Oscar Vilaplana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed tests, added docs, renamed helper method
parent
6bbedfd7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
15 deletions
+22
-15
rest_framework/tests/fields.py
+13
-9
rest_framework/tests/generics.py
+2
-0
rest_framework/views.py
+7
-6
No files found.
rest_framework/tests/fields.py
View file @
7a5cd090
...
@@ -15,8 +15,8 @@ from django.test import TestCase
...
@@ -15,8 +15,8 @@ from django.test import TestCase
from
django.utils.datastructures
import
SortedDict
from
django.utils.datastructures
import
SortedDict
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
rest_framework.fields
import
(
humanize_field
,
humanize_field_type
,
humanize_form_fields
,
from
rest_framework.fields
import
(
humanize_field
,
humanize_field_type
,
Field
)
humanize_form_fields
,
Field
)
from
rest_framework.serializers
import
Serializer
from
rest_framework.serializers
import
Serializer
from
rest_framework.tests.models
import
RESTFrameworkModel
from
rest_framework.tests.models
import
RESTFrameworkModel
...
@@ -882,10 +882,14 @@ class HumanizedSerializer(TestCase):
...
@@ -882,10 +882,14 @@ class HumanizedSerializer(TestCase):
def
test_humanized
(
self
):
def
test_humanized
(
self
):
humanized
=
humanize_form_fields
(
Form
())
humanized
=
humanize_form_fields
(
Form
())
self
.
assertEqual
(
humanized
,
{
expected
=
{
'field1'
:
{
'field1'
:
{
u'help_text'
:
u''
,
u'help_text'
:
u''
,
u'required'
:
True
,
u'label'
:
u'field one'
,
u'type'
:
u'String'
,
u'label'
:
'field one'
},
u'max_length'
:
3
,
'field2'
:
{
u'required'
:
True
,
u'help_text'
:
u''
,
u'required'
:
True
,
u'type'
:
u'String'
},
u'type'
:
u'String'
,
u'label'
:
'field two'
}})
'field2'
:
{
u'help_text'
:
u''
,
u'label'
:
u'field two'
,
u'required'
:
True
,
u'type'
:
u'String'
}}
self
.
assertEqual
(
humanized
,
expected
)
rest_framework/tests/generics.py
View file @
7a5cd090
...
@@ -131,6 +131,7 @@ class TestRootView(TestCase):
...
@@ -131,6 +131,7 @@ class TestRootView(TestCase):
# TODO add help_text and label when they are available
# TODO add help_text and label when they are available
#'help_text': '',
#'help_text': '',
#'label': None,
#'label': None,
'max_length'
:
100
,
'read_only'
:
False
,
'read_only'
:
False
,
'required'
:
True
,
'required'
:
True
,
'type'
:
'String'
,
'type'
:
'String'
,
...
@@ -272,6 +273,7 @@ class TestInstanceView(TestCase):
...
@@ -272,6 +273,7 @@ class TestInstanceView(TestCase):
# available
# available
#'description': '',
#'description': '',
#'label': None,
#'label': None,
'max_length'
:
100
,
'read_only'
:
False
,
'read_only'
:
False
,
'required'
:
True
,
'required'
:
True
,
'type'
:
'String'
,
'type'
:
'String'
,
...
...
rest_framework/views.py
View file @
7a5cd090
...
@@ -61,15 +61,16 @@ class APIView(View):
...
@@ -61,15 +61,16 @@ class APIView(View):
'renders'
:
[
renderer
.
media_type
for
renderer
in
self
.
renderer_classes
],
'renders'
:
[
renderer
.
media_type
for
renderer
in
self
.
renderer_classes
],
'parses'
:
[
parser
.
media_type
for
parser
in
self
.
parser_classes
],
'parses'
:
[
parser
.
media_type
for
parser
in
self
.
parser_classes
],
}
}
action_metadata
=
self
.
_generate_action_metadata
(
request
)
content
[
'actions'
]
=
self
.
action_metadata
(
request
)
if
action_metadata
is
not
None
:
content
[
'actions'
]
=
action_metadata
return
content
return
content
def
_generate_action_metadata
(
self
,
request
):
def
action_metadata
(
self
,
request
):
"""
"""Return a dictionary with the fields required fo reach allowed method. If no method is allowed,
Helper for generating the fields metadata for allowed and permitted methods.
return an empty dictionary.
:param request: Request for which to return the metadata of the allowed methods.
:return: A dictionary of the form {method: {field: {field attribute: value}}}
"""
"""
actions
=
{}
actions
=
{}
for
method
in
self
.
allowed_methods
:
for
method
in
self
.
allowed_methods
:
...
...
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