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
9eaf8e43
Commit
9eaf8e43
authored
Dec 13, 2012
by
Simon Pantzare
Committed by
Tom Christie
Dec 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test to verify that context is passed on
The paginator and its object serializer should share the same context.
parent
50f46124
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
+13
-1
rest_framework/tests/pagination.py
+13
-1
No files found.
rest_framework/tests/pagination.py
View file @
9eaf8e43
...
@@ -4,7 +4,7 @@ from django.core.paginator import Paginator
...
@@ -4,7 +4,7 @@ from django.core.paginator import Paginator
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
from
django.test.client
import
RequestFactory
from
django.utils
import
unittest
from
django.utils
import
unittest
from
rest_framework
import
generics
,
status
,
pagination
,
filters
from
rest_framework
import
generics
,
status
,
pagination
,
filters
,
serializers
from
rest_framework.compat
import
django_filters
from
rest_framework.compat
import
django_filters
from
rest_framework.tests.models
import
BasicModel
,
FilterableItem
from
rest_framework.tests.models
import
BasicModel
,
FilterableItem
...
@@ -148,6 +148,12 @@ class IntegrationTestPaginationAndFiltering(TestCase):
...
@@ -148,6 +148,12 @@ class IntegrationTestPaginationAndFiltering(TestCase):
self
.
assertEquals
(
response
.
data
[
'previous'
],
None
)
self
.
assertEquals
(
response
.
data
[
'previous'
],
None
)
class
PassOnContextPaginationSerializer
(
pagination
.
PaginationSerializer
):
class
Meta
:
object_serializer_class
=
serializers
.
Serializer
class
UnitTestPagination
(
TestCase
):
class
UnitTestPagination
(
TestCase
):
"""
"""
Unit tests for pagination of primitive objects.
Unit tests for pagination of primitive objects.
...
@@ -172,6 +178,12 @@ class UnitTestPagination(TestCase):
...
@@ -172,6 +178,12 @@ class UnitTestPagination(TestCase):
self
.
assertEquals
(
serializer
.
data
[
'previous'
],
'?page=2'
)
self
.
assertEquals
(
serializer
.
data
[
'previous'
],
'?page=2'
)
self
.
assertEquals
(
serializer
.
data
[
'results'
],
self
.
objects
[
20
:])
self
.
assertEquals
(
serializer
.
data
[
'results'
],
self
.
objects
[
20
:])
def
test_context_available_in_result
(
self
):
serializer
=
PassOnContextPaginationSerializer
(
self
.
first_page
)
results
=
serializer
.
fields
[
serializer
.
results_field
]
# assertIs is available in Python 2.7
self
.
assertTrue
(
serializer
.
context
is
results
.
context
)
class
TestUnpaginated
(
TestCase
):
class
TestUnpaginated
(
TestCase
):
"""
"""
...
...
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