summaryrefslogtreecommitdiff
path: root/openstackclient/tests/volume/v2/fakes.py
diff options
context:
space:
mode:
authorting.wang <ting.wang@easystack.cn>2016-05-12 10:13:13 +0800
committerting wang <bx_wang@outlook.com>2016-05-17 20:14:18 +0800
commit0fa2e8df92986bf7cbbba131042c1d3196b54365 (patch)
treee4f7a607cb716a2af4b8c1b15ac51bf3c4459486 /openstackclient/tests/volume/v2/fakes.py
parent553e154960c6a9da8481c4602c0a7a0d1147d2ad (diff)
downloadpython-openstackclient-0fa2e8df92986bf7cbbba131042c1d3196b54365.tar.gz
Refactor TestVolumeShow with FakeVolume
In the meantime, add some static methods in FakeVolume for ease of use and add info() method with "property" decorator in FakeResource to allow those static methods to get fake information. Change-Id: I98ad520f32afd529fda77a4592f645130282537f Co-Authored-By: xiexs <xiexs@cn.fujitsu.com> Implements: blueprint improve-volume-unittest-framework
Diffstat (limited to 'openstackclient/tests/volume/v2/fakes.py')
-rw-r--r--openstackclient/tests/volume/v2/fakes.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/openstackclient/tests/volume/v2/fakes.py b/openstackclient/tests/volume/v2/fakes.py
index fc45e47b..ebb0c2ff 100644
--- a/openstackclient/tests/volume/v2/fakes.py
+++ b/openstackclient/tests/volume/v2/fakes.py
@@ -451,6 +451,44 @@ class FakeVolume(object):
return mock.MagicMock(side_effect=volumes)
+ @staticmethod
+ def get_volume_columns(volume=None):
+ """Get the volume columns from a faked volume object.
+
+ :param volume:
+ A FakeResource objects faking volume
+ :return
+ A tuple which may include the following keys:
+ ('id', 'name', 'description', 'status', 'size', 'volume_type',
+ 'metadata', 'snapshot', 'availability_zone', 'attachments')
+ """
+ if volume is not None:
+ return tuple(k for k in sorted(volume.keys()))
+ return tuple([])
+
+ @staticmethod
+ def get_volume_data(volume=None):
+ """Get the volume data from a faked volume object.
+
+ :param volume:
+ A FakeResource objects faking volume
+ :return
+ A tuple which may include the following values:
+ ('ce26708d', 'fake_volume', 'fake description', 'available',
+ 20, 'fake_lvmdriver-1', "Alpha='a', Beta='b', Gamma='g'",
+ 1, 'nova', [{'device': '/dev/ice', 'server_id': '1233'}])
+ """
+ data_list = []
+ if volume is not None:
+ for x in sorted(volume.keys()):
+ if x == 'tags':
+ # The 'tags' should be format_list
+ data_list.append(
+ common_utils.format_list(volume.info.get(x)))
+ else:
+ data_list.append(volume.info.get(x))
+ return tuple(data_list)
+
class FakeAvailabilityZone(object):
"""Fake one or more volume availability zones (AZs)."""