-
Notifications
You must be signed in to change notification settings - Fork 301
Issue 430: pagination enhancement #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
4507ab9
6589946
9403a07
fcdfa90
0b136eb
863feeb
2b437dc
0439081
7c53996
8569fd9
ab7fb38
f5195a9
284a3d6
31fe58b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
from collections import OrderedDict | ||
|
||
import pytest | ||
from rest_framework.request import Request | ||
from rest_framework.test import APIRequestFactory | ||
from rest_framework.utils.urls import replace_query_param | ||
|
||
from rest_framework_json_api.pagination import LimitOffsetPagination | ||
from rest_framework_json_api import pagination | ||
|
||
factory = APIRequestFactory() | ||
|
||
|
||
class TestLimitOffset: | ||
""" | ||
Unit tests for `pagination.LimitOffsetPagination`. | ||
Unit tests for `pagination.JsonApiLimitOffsetPagination`. | ||
""" | ||
|
||
def setup(self): | ||
class ExamplePagination(LimitOffsetPagination): | ||
class ExamplePagination(pagination.JsonApiLimitOffsetPagination): | ||
default_limit = 10 | ||
max_limit = 15 | ||
|
||
|
@@ -76,3 +77,22 @@ def test_valid_offset_limit(self): | |
|
||
assert queryset == list(range(offset + 1, next_offset + 1)) | ||
assert content == expected_content | ||
|
||
def test_LimitOffset_deprecation(self): | ||
with pytest.warns(DeprecationWarning) as record: | ||
pagination.LimitOffsetPagination() | ||
assert len(record) == 1 | ||
assert 'LimitOffsetPagination' in str(record[0].message) | ||
|
||
|
||
# TODO: This test fails under py27 but it's not clear why so just leave it out for now. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a pytest feature called xfail. See https://docs.pytest.org/en/latest/skipping.html So instead of commenting this out you can mark it as This is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. Got caught by flake8 again (#436 will address this if and when done) |
||
# class TestPageNumber: | ||
# """ | ||
# Unit tests for `pagination.JsonApiPageNumberPagination`. | ||
# TODO: add unit tests for changing query parameter names, limits, etc. | ||
# """ | ||
# def test_PageNumber_deprecation(self): | ||
# with pytest.warns(DeprecationWarning) as record: | ||
# pagination.PageNumberPagination() | ||
# assert len(record) == 1 | ||
# assert 'PageNumberPagination' in str(record[0].message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods name should always be all snake cased and lowercase.