add condition for when no assets are found in the database

This commit is contained in:
Michael Roytman
2018-01-23 13:07:22 -05:00
parent 948cae4148
commit 97954d48fb
2 changed files with 5 additions and 1 deletions

View File

@@ -138,7 +138,7 @@ def _assets_json(request, course_key):
assets, total_count = _get_assets_for_page(course_key, query_options)
if request_options['requested_page'] > 0 and first_asset_to_display_index >= total_count:
if request_options['requested_page'] > 0 and first_asset_to_display_index >= total_count and total_count > 0:
_update_options_to_requery_final_page(query_options, total_count)
current_page = query_options['current_page']
first_asset_to_display_index = _get_first_asset_index(current_page, requested_page_size)

View File

@@ -191,6 +191,10 @@ class PaginationTestCase(AssetsTestCase):
self.url + "?page_size=2&page=2", 2, 2, 4)
self.assert_correct_asset_response(
self.url + "?page_size=3&page=1", 3, 1, 4)
self.assert_correct_asset_response(
self.url + "?page_size=1&page=5&asset_type=OTHER", 0, 1, 1)
self.assert_correct_asset_response(
self.url + "?page_size=1&page=5&asset_type=Images", 5, 0, 0)
@mock.patch('xmodule.contentstore.mongo.MongoContentStore.get_all_content_for_course')
def test_mocked_filtered_response(self, mock_get_all_content_for_course):