summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/image/v1/test_image.py
diff options
context:
space:
mode:
authorBadhmapriya Boopalan <Badhmapriya.Boopalan@cognizant.com>2016-11-15 19:55:46 +0000
committerSteve Martinelli <s.martinelli@gmail.com>2017-01-11 02:09:02 +0000
commit6962cc963e6e17e709524ecf6a395e2d0c8b8370 (patch)
tree768386a18e543cff9fb36e727550b2b8a7b4df46 /openstackclient/tests/unit/image/v1/test_image.py
parent5bf5de6f45a9a96768de9aafdb8cd1bb390389aa (diff)
downloadpython-openstackclient-6962cc963e6e17e709524ecf6a395e2d0c8b8370.tar.gz
To display image size in human friendly format
Include option '--human-readable' to 'image show' command. This option displays image size in human readable format (such as K, M, G, T,..) Related Commit: I0ef74c2ec978483fe49156c88acf5c369a8fa5c2 Closes-Bug: #1640086 Change-Id: I28cd5702925d51303d0607ed8dccf12c56434682
Diffstat (limited to 'openstackclient/tests/unit/image/v1/test_image.py')
-rw-r--r--openstackclient/tests/unit/image/v1/test_image.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/openstackclient/tests/unit/image/v1/test_image.py b/openstackclient/tests/unit/image/v1/test_image.py
index aef74f04..6b7560aa 100644
--- a/openstackclient/tests/unit/image/v1/test_image.py
+++ b/openstackclient/tests/unit/image/v1/test_image.py
@@ -692,7 +692,8 @@ class TestImageSet(TestImage):
class TestImageShow(TestImage):
- _image = image_fakes.FakeImage.create_one_image()
+ _image = image_fakes.FakeImage.create_one_image(
+ attrs={'size': 2000})
columns = (
'container_format',
'disk_format',
@@ -704,6 +705,7 @@ class TestImageShow(TestImage):
'owner',
'properties',
'protected',
+ 'size',
)
data = (
_image.container_format,
@@ -716,6 +718,7 @@ class TestImageShow(TestImage):
_image.owner,
utils.format_dict(_image.properties),
_image.protected,
+ _image.size,
)
def setUp(self):
@@ -745,3 +748,25 @@ class TestImageShow(TestImage):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
+
+ def test_image_show_human_readable(self):
+ arglist = [
+ '--human-readable',
+ self._image.id,
+ ]
+ verifylist = [
+ ('human_readable', True),
+ ('image', self._image.id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # In base command class ShowOne in cliff, abstract method take_action()
+ # returns a two-part tuple with a tuple of column names and a tuple of
+ # data to be shown.
+ columns, data = self.cmd.take_action(parsed_args)
+ self.images_mock.get.assert_called_with(
+ self._image.id,
+ )
+
+ size_index = columns.index('size')
+ self.assertEqual(data[size_index], '2K')