summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/volume/v2/test_volume.py
diff options
context:
space:
mode:
authorRui Chen <chenrui.momo@gmail.com>2017-01-20 14:37:14 +0800
committerRui Chen <chenrui.momo@gmail.com>2017-05-26 11:37:09 +0800
commit6aceca218af7d1d2c708fde48f1a5f2b798bc421 (patch)
treef61ad5a7cfd347a2f94646e2a1b305932e13dee1 /openstackclient/tests/functional/volume/v2/test_volume.py
parentb78153aec4f050e64ee8ec9c930ae673bb3ecd47 (diff)
downloadpython-openstackclient-6aceca218af7d1d2c708fde48f1a5f2b798bc421.tar.gz
Replace "Display Name" by "Name" in volume list
Current "volume list --name" command use "display_name" as search_opts to send to cinder API, and show the result table with "Display Name" column title in osc, cinder list API support "name" as search opts too, and there is "name" attribute in volume response body, so we can replace all "Display Name" by "Name" in order to keep "volume list" command consistent with other commands, like: server list, network list and so on, only use "Name" attribute for all objects. Support a mapping for volume list -c "Display Name" (Volume v1 and v2) and volume create/show -c "display_name" (Volume v1) for minimal backward compatibility until R release. Change-Id: I120be0118e7bb30093b4237c5eeb69a9eedef077 Closes-Bug: #1657956 Depends-On: I1fb62219b092346ea380099811cbd082cae5bafe
Diffstat (limited to 'openstackclient/tests/functional/volume/v2/test_volume.py')
-rw-r--r--openstackclient/tests/functional/volume/v2/test_volume.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/openstackclient/tests/functional/volume/v2/test_volume.py b/openstackclient/tests/functional/volume/v2/test_volume.py
index 94ac792f..f936907c 100644
--- a/openstackclient/tests/functional/volume/v2/test_volume.py
+++ b/openstackclient/tests/functional/volume/v2/test_volume.py
@@ -90,7 +90,7 @@ class VolumeTests(common.BaseVolumeTests):
'volume list -f json ' +
'--long'
))
- names = [x["Display Name"] for x in cmd_output]
+ names = [x["Name"] for x in cmd_output]
self.assertIn(name1, names)
self.assertIn(name2, names)
@@ -99,7 +99,7 @@ class VolumeTests(common.BaseVolumeTests):
'volume list -f json ' +
'--status error'
))
- names = [x["Display Name"] for x in cmd_output]
+ names = [x["Name"] for x in cmd_output]
self.assertNotIn(name1, names)
self.assertIn(name2, names)
@@ -249,6 +249,37 @@ class VolumeTests(common.BaseVolumeTests):
'volume snapshot delete ' + snapshot_name)
self.assertOutput('', raw_output)
+ def test_volume_list_backward_compatibility(self):
+ """Test backward compatibility of list command"""
+ name1 = uuid.uuid4().hex
+ cmd_output = json.loads(self.openstack(
+ 'volume create -f json ' +
+ '--size 1 ' +
+ name1
+ ))
+ self.addCleanup(self.openstack, 'volume delete ' + name1)
+ self.assertEqual(
+ 1,
+ cmd_output["size"],
+ )
+ self.wait_for("volume", name1, "available")
+
+ # Test list -c "Display Name"
+ cmd_output = json.loads(self.openstack(
+ 'volume list -f json ' +
+ '-c "Display Name"'
+ ))
+ for each_volume in cmd_output:
+ self.assertIn('Display Name', each_volume)
+
+ # Test list -c "Name"
+ cmd_output = json.loads(self.openstack(
+ 'volume list -f json ' +
+ '-c "Name"'
+ ))
+ for each_volume in cmd_output:
+ self.assertIn('Name', each_volume)
+
def wait_for(self, check_type, check_name, desired_status, wait=120,
interval=5, failures=['ERROR']):
status = "notset"