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
deb19272
Commit
deb19272
authored
Sep 03, 2014
by
Michał Jaworski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add custom pagination test that covers case with custom object serializer class
parent
b40525d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
tests/test_pagination.py
+19
-0
No files found.
tests/test_pagination.py
View file @
deb19272
...
@@ -412,6 +412,15 @@ class CustomPaginationSerializer(pagination.BasePaginationSerializer):
...
@@ -412,6 +412,15 @@ class CustomPaginationSerializer(pagination.BasePaginationSerializer):
results_field
=
'objects'
results_field
=
'objects'
class
CustomFooSerializer
(
serializers
.
Serializer
):
foo
=
serializers
.
CharField
()
class
CustomFooPaginationSerializer
(
pagination
.
PaginationSerializer
):
class
Meta
:
object_serializer_class
=
CustomFooSerializer
class
TestCustomPaginationSerializer
(
TestCase
):
class
TestCustomPaginationSerializer
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
objects
=
[
'john'
,
'paul'
,
'george'
,
'ringo'
]
objects
=
[
'john'
,
'paul'
,
'george'
,
'ringo'
]
...
@@ -434,6 +443,16 @@ class TestCustomPaginationSerializer(TestCase):
...
@@ -434,6 +443,16 @@ class TestCustomPaginationSerializer(TestCase):
}
}
self
.
assertEqual
(
serializer
.
data
,
expected
)
self
.
assertEqual
(
serializer
.
data
,
expected
)
def
test_custom_pagination_serializer_with_custom_object_serializer
(
self
):
objects
=
[
{
'foo'
:
'bar'
},
{
'foo'
:
'spam'
}
]
paginator
=
Paginator
(
objects
,
1
)
page
=
paginator
.
page
(
1
)
serializer
=
CustomFooPaginationSerializer
(
page
)
serializer
.
data
class
NonIntegerPage
(
object
):
class
NonIntegerPage
(
object
):
...
...
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