Skip to content

Commit

Permalink
Remove marker and loop from "image list" command
Browse files Browse the repository at this point in the history
Since --page-size has never worked, there is no paginate logic needs
to be implemented in "image list" command. So remove the unnecessary
loop.

And also, the marker is not necessary because --marker option has not
been implemented. Will add it back when implementing --marker option.

Change-Id: I71fea1502f92f447a49697edb52e8e82f336772f
Partial-Bug: #1540988
  • Loading branch information
Tang Chen committed Feb 3, 2016
1 parent 4b2c664 commit 0b6fdcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
11 changes: 1 addition & 10 deletions openstackclient/image/v2/image.py
Expand Up @@ -474,16 +474,7 @@ def take_action(self, parsed_args):
column_headers = columns

# List of image data received
data = []
# No pages received yet, so start the page marker at None.
marker = None
while True:
page = image_client.api.image_list(marker=marker, **kwargs)
if not page:
break
data.extend(page)
# Set the marker to the id of the last item we received
marker = page[-1]['id']
data = image_client.api.image_list(**kwargs)

if parsed_args.property:
# NOTE(dtroyer): coerce to a list to subscript it in py3
Expand Down
19 changes: 4 additions & 15 deletions openstackclient/tests/image/v2/test_image.py
Expand Up @@ -498,9 +498,7 @@ def test_image_list_no_options(self):

# DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
marker=image_fakes.image_id,
)
self.api_mock.image_list.assert_called_with()

self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, tuple(data))
Expand All @@ -521,7 +519,6 @@ def test_image_list_public_option(self):
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
public=True,
marker=image_fakes.image_id,
)

self.assertEqual(self.columns, columns)
Expand All @@ -543,7 +540,6 @@ def test_image_list_private_option(self):
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
private=True,
marker=image_fakes.image_id,
)

self.assertEqual(self.columns, columns)
Expand All @@ -565,7 +561,6 @@ def test_image_list_shared_option(self):
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
shared=True,
marker=image_fakes.image_id,
)

self.assertEqual(self.columns, columns)
Expand All @@ -582,9 +577,7 @@ def test_image_list_long_option(self):

# DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
marker=image_fakes.image_id,
)
self.api_mock.image_list.assert_called_with()

collist = (
'ID',
Expand Down Expand Up @@ -630,9 +623,7 @@ def test_image_list_property_option(self, sf_mock):

# DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
marker=image_fakes.image_id,
)
self.api_mock.image_list.assert_called_with()
sf_mock.assert_called_with(
[image_fakes.IMAGE],
attr='a',
Expand All @@ -655,9 +646,7 @@ def test_image_list_sort_option(self, si_mock):

# DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with(
marker=image_fakes.image_id,
)
self.api_mock.image_list.assert_called_with()
si_mock.assert_called_with(
[image_fakes.IMAGE],
'name:asc'
Expand Down

0 comments on commit 0b6fdcb

Please sign in to comment.