Merge "Enable pagination for Project->Images view"
This commit is contained in:
commit
ae13e41cf1
@ -41,8 +41,9 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
||||
def test_index(self):
|
||||
images = self.images.list()
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None).AndReturn([images,
|
||||
False, False])
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([images, False, False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(INDEX_URL)
|
||||
@ -66,8 +67,9 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
||||
@test.create_stubs({api.glance: ('image_list_detailed',)})
|
||||
def test_index_no_images(self):
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None).AndReturn([(),
|
||||
False, False])
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([(), False, False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(INDEX_URL)
|
||||
@ -76,7 +78,8 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
||||
@test.create_stubs({api.glance: ('image_list_detailed',)})
|
||||
def test_index_error(self):
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None) \
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndRaise(self.exceptions.glance)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -86,7 +89,9 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
||||
@test.create_stubs({api.glance: ('image_list_detailed',)})
|
||||
def test_snapshot_actions(self):
|
||||
snapshots = self.snapshots.list()
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest), marker=None) \
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([snapshots, False, False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -38,18 +38,19 @@ class IndexView(tables.DataTableView):
|
||||
page_title = _("Images")
|
||||
|
||||
def has_prev_data(self, table):
|
||||
return getattr(self, "_prev_%s" % table.name, False)
|
||||
return getattr(self, "_prev", False)
|
||||
|
||||
def has_more_data(self, table):
|
||||
return getattr(self, "_more_%s" % table.name, False)
|
||||
return getattr(self, "_more", False)
|
||||
|
||||
def get_data(self):
|
||||
marker = self.request.GET.get(
|
||||
images_tables.ImagesTable._meta.pagination_param, None)
|
||||
try:
|
||||
(images, self._more, self._prev) = api.glance.image_list_detailed(
|
||||
self.request, marker=marker)
|
||||
|
||||
self.request,
|
||||
marker=marker,
|
||||
paginate=True)
|
||||
except Exception:
|
||||
images = []
|
||||
exceptions.handle(self.request, _("Unable to retrieve images."))
|
||||
|
@ -1234,8 +1234,9 @@ class InstanceTests(helpers.TestCase):
|
||||
"snapshot1").AndReturn(self.snapshots.first())
|
||||
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None).AndReturn([[], False,
|
||||
False])
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([[], False, False])
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user