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
80f15c59
Commit
80f15c59
authored
Dec 11, 2012
by
George Kappel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added depth test
parent
80adaecc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
rest_framework/runtests/runtests.py
+5
-0
rest_framework/tests/serializer.py
+21
-0
No files found.
rest_framework/runtests/runtests.py
View file @
80f15c59
...
...
@@ -5,6 +5,11 @@
# http://code.djangoproject.com/svn/django/trunk/tests/runtests.py
import
os
import
sys
"""
Need to fix sys path so following works without specifically messing with PYTHONPATH
python ./rest_framework/runtests/runtests.py
"""
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"../.."
))
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'rest_framework.runtests.settings'
from
django.conf
import
settings
...
...
rest_framework/tests/serializer.py
View file @
80f15c59
...
...
@@ -726,3 +726,24 @@ class SerializerPickleTests(TestCase):
model
=
Person
fields
=
(
'name'
,
'age'
)
pickle
.
dumps
(
InnerPersonSerializer
(
Person
(
name
=
"Noah"
,
age
=
950
))
.
data
)
class
DepthTest
(
TestCase
):
def
test_depth
(
self
):
user
=
Person
.
objects
.
create
(
name
=
"django"
,
age
=
1
)
post
=
BlogPost
.
objects
.
create
(
title
=
"Test blog post"
,
writer
=
user
)
class
PersonSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Person
fields
=
(
"name"
,
"age"
)
class
BlogPostSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
BlogPost
depth
=
1
serializer
=
BlogPostSerializer
(
instance
=
post
)
expected
=
{
'id'
:
1
,
'title'
:
u'Test blog post'
,
'writer'
:
{
'id'
:
1
,
'name'
:
u'django'
,
'age'
:
1
}}
self
.
assertEqual
(
serializer
.
data
,
expected
)
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