Skip to content

Commit 8175f05

Browse files
authored
Added pagination settings test case (#8362)
1 parent 0ae3323 commit 8175f05

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_settings.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@ def test_compatibility_with_override_settings(self):
4343

4444
assert api_settings.PAGE_SIZE is None, "Setting should have been restored"
4545

46+
def test_pagination_settings(self):
47+
"""
48+
Integration tests for pagination system check.
49+
"""
50+
from rest_framework.checks import pagination_system_check
51+
52+
def get_pagination_error(error_id: str):
53+
errors = pagination_system_check(app_configs=None)
54+
return next((error for error in errors if error.id == error_id), None)
55+
56+
self.assertIsNone(api_settings.PAGE_SIZE)
57+
self.assertIsNone(api_settings.DEFAULT_PAGINATION_CLASS)
58+
59+
pagination_error = get_pagination_error('rest_framework.W001')
60+
self.assertIsNone(pagination_error)
61+
62+
with override_settings(REST_FRAMEWORK={'PAGE_SIZE': 10}):
63+
pagination_error = get_pagination_error('rest_framework.W001')
64+
self.assertIsNotNone(pagination_error)
65+
66+
default_pagination_class = 'rest_framework.pagination.PageNumberPagination'
67+
with override_settings(REST_FRAMEWORK={'PAGE_SIZE': 10, 'DEFAULT_PAGINATION_CLASS': default_pagination_class}):
68+
pagination_error = get_pagination_error('rest_framework.W001')
69+
self.assertIsNone(pagination_error)
70+
4671

4772
class TestSettingTypes(TestCase):
4873
def test_settings_consistently_coerced_to_list(self):

0 commit comments

Comments
 (0)