def test_pagination(self): PostFactory.create_batch(20) PostFactory(status=0) response = api_client.get('/api/post/all/', format='json') self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data['results']), 10) self.assertEqual(response.data['count'], 25) self.assertEqual(response.data['next'], 'https://testserver:80/api/post/all/?page=2') response = api_client.get('/api/post/all/?page=2', format='json') self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data['results']), 10)
def setUp(self): PostFactory.create_batch(7)
def test_posts_list(self): PostFactory.create_batch(size=11) self.assertEqual(len(posts_list(10)['posts']), 10) self.assertEqual(len(posts_list(5)['posts']), 5)