'Test cases in which pagination is done by the comments service.
thread_type is the type of thread (question or discussion).
endorsed_arg is the value of the endorsed argument.
repsonse_field is the field in which responses are returned for the
given thread type.
response_total_field is the field in which the total number of responses
is returned for the given thread type.'

@ddt.data(('discussion', None, 'children', 'resp_total'), ('question', False, 'non_endorsed_responses', 'non_endorsed_resp_total'))
@ddt.unpack
def test_cs_pagination(self, thread_type, endorsed_arg, response_field, response_total_field):

    thread = self.make_minimal_cs_thread({'thread_type': thread_type, response_field: [make_minimal_cs_comment({'username': self.user.username})], response_total_field: 5})
    actual = self.get_comment_list(thread, endorsed=endorsed_arg, page=1, page_size=5).data
    self.assertIsNone(actual['pagination']['next'])
    self.assertIsNone(actual['pagination']['previous'])
    actual = self.get_comment_list(thread, endorsed=endorsed_arg, page=1, page_size=2).data
    self.assertEqual(actual['pagination']['next'], 'http://testserver/test_path?page=2')
    self.assertIsNone(actual['pagination']['previous'])
    actual = self.get_comment_list(thread, endorsed=endorsed_arg, page=2, page_size=2).data
    self.assertEqual(actual['pagination']['next'], 'http://testserver/test_path?page=3')
    self.assertEqual(actual['pagination']['previous'], 'http://testserver/test_path?page=1')
    actual = self.get_comment_list(thread, endorsed=endorsed_arg, page=3, page_size=2).data
    self.assertIsNone(actual['pagination']['next'])
    self.assertEqual(actual['pagination']['previous'], 'http://testserver/test_path?page=2')
    thread = self.make_minimal_cs_thread({'thread_type': thread_type, response_field: [], response_total_field: 5})
    with self.assertRaises(PageNotFoundError):
        self.get_comment_list(thread, endorsed=endorsed_arg, page=2, page_size=5)
