'Test that requesting bookmarks for a course returns records successfully in
expected order without optional fields.'

@ddt.data((1, False), (10, False), (25, False), (1, True), (10, True), (25, True))
@ddt.unpack
@patch('eventtracking.tracker.emit')
def test_get_bookmarks_successfully(self, bookmarks_count, check_all_fields, mock_tracker):

    (course, __, bookmarks) = self.create_course_with_bookmarks_count(bookmarks_count, store_type=ModuleStoreEnum.Type.mongo)
    query_parameters = 'course_id={}&page_size={}'.format(urllib.quote(unicode(course.id)), 100)
    if check_all_fields:
        query_parameters += '&fields=path,display_name'
    response = self.send_get(client=self.client, url=reverse('bookmarks'), query_parameters=query_parameters)
    bookmarks_data = response.data['results']
    self.assertEqual(len(bookmarks_data), len(bookmarks))
    self.assertEqual(response.data['count'], len(bookmarks))
    self.assertEqual(response.data['num_pages'], 1)
    self.assert_bookmark_data_is_valid(bookmarks[(-1)], bookmarks_data[0], check_optional_fields=check_all_fields)
    self.assert_bookmark_data_is_valid(bookmarks[0], bookmarks_data[(-1)], check_optional_fields=check_all_fields)
    self.assert_bookmark_event_emitted(mock_tracker, event_name='edx.bookmark.listed', course_id=unicode(course.id), list_type='per_course', bookmarks_count=bookmarks_count, page_size=100, page_number=1)
