Add custom pagination test that covers case with custom object serializer class

This commit is contained in:
Michał Jaworski 2014-09-03 16:49:32 +02:00
parent b40525d8e6
commit deb19272b7

View File

@ -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):