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
b3716ccb
Commit
b3716ccb
authored
Jun 14, 2015
by
homm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make MockObject, MockQuerySet and ExamplePagination visible outside of setup
parent
ab03729b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
tests/test_pagination.py
+10
-10
No files found.
tests/test_pagination.py
View file @
b3716ccb
...
@@ -186,6 +186,7 @@ class TestPageNumberPagination:
...
@@ -186,6 +186,7 @@ class TestPageNumberPagination:
def
setup
(
self
):
def
setup
(
self
):
class
ExamplePagination
(
pagination
.
PageNumberPagination
):
class
ExamplePagination
(
pagination
.
PageNumberPagination
):
page_size
=
5
page_size
=
5
self
.
pagination
=
ExamplePagination
()
self
.
pagination
=
ExamplePagination
()
self
.
queryset
=
range
(
1
,
101
)
self
.
queryset
=
range
(
1
,
101
)
...
@@ -475,32 +476,30 @@ class TestCursorPagination:
...
@@ -475,32 +476,30 @@ class TestCursorPagination:
"""
"""
Unit tests for `pagination.CursorPagination`.
Unit tests for `pagination.CursorPagination`.
"""
"""
def
setup
(
self
):
class
MockObject
(
object
):
class
MockObject
(
object
):
def
__init__
(
self
,
idx
):
def
__init__
(
self
,
idx
):
self
.
created
=
idx
self
.
created
=
idx
class
MockQuerySet
(
object
):
class
MockQuerySet
(
object
):
def
__init__
(
self
,
items
):
def
__init__
(
self
,
items
):
self
.
items
=
items
self
.
items
=
list
(
items
)
def
filter
(
self
,
created__gt
=
None
,
created__lt
=
None
):
def
filter
(
self
,
created__gt
=
None
,
created__lt
=
None
):
if
created__gt
is
not
None
:
if
created__gt
is
not
None
:
return
MockQuerySet
([
return
type
(
self
)
([
item
for
item
in
self
.
items
item
for
item
in
self
.
items
if
item
.
created
>
int
(
created__gt
)
if
item
.
created
>
int
(
created__gt
)
])
])
assert
created__lt
is
not
None
assert
created__lt
is
not
None
return
MockQuerySet
([
return
type
(
self
)
([
item
for
item
in
self
.
items
item
for
item
in
self
.
items
if
item
.
created
<
int
(
created__lt
)
if
item
.
created
<
int
(
created__lt
)
])
])
def
order_by
(
self
,
*
ordering
):
def
order_by
(
self
,
*
ordering
):
if
ordering
[
0
]
.
startswith
(
'-'
):
if
ordering
[
0
]
.
startswith
(
'-'
):
return
MockQuerySet
(
list
(
reversed
(
self
.
items
)))
return
type
(
self
)
(
list
(
reversed
(
self
.
items
)))
return
self
return
self
def
__getitem__
(
self
,
sliced
):
def
__getitem__
(
self
,
sliced
):
...
@@ -510,17 +509,18 @@ class TestCursorPagination:
...
@@ -510,17 +509,18 @@ class TestCursorPagination:
page_size
=
5
page_size
=
5
ordering
=
'created'
ordering
=
'created'
self
.
pagination
=
ExamplePagination
()
def
setup
(
self
):
self
.
queryset
=
MockQuerySet
([
self
.
pagination
=
self
.
ExamplePagination
()
MockObject
(
idx
)
for
idx
in
[
self
.
queryset
=
self
.
MockQuerySet
(
map
(
self
.
MockObject
,
[
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
3
,
4
,
4
,
1
,
2
,
3
,
4
,
4
,
4
,
4
,
5
,
6
,
7
,
4
,
4
,
5
,
6
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
8
,
9
,
7
,
7
,
7
,
8
,
9
,
9
,
9
,
9
,
9
,
9
9
,
9
,
9
,
9
,
9
]
])
])
)
def
get_pages
(
self
,
url
):
def
get_pages
(
self
,
url
):
"""
"""
...
...
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