mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Add custom pagination test that covers case with custom object serializer class
This commit is contained in:
parent
b40525d8e6
commit
deb19272b7
|
@ -412,6 +412,15 @@ class CustomPaginationSerializer(pagination.BasePaginationSerializer):
|
|||
results_field = 'objects'
|
||||
|
||||
|
||||
class CustomFooSerializer(serializers.Serializer):
|
||||
foo = serializers.CharField()
|
||||
|
||||
|
||||
class CustomFooPaginationSerializer(pagination.PaginationSerializer):
|
||||
class Meta:
|
||||
object_serializer_class = CustomFooSerializer
|
||||
|
||||
|
||||
class TestCustomPaginationSerializer(TestCase):
|
||||
def setUp(self):
|
||||
objects = ['john', 'paul', 'george', 'ringo']
|
||||
|
@ -434,6 +443,16 @@ class TestCustomPaginationSerializer(TestCase):
|
|||
}
|
||||
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):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user