summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/volume/v1/test_snapshot.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/tests/functional/volume/v1/test_snapshot.py')
-rw-r--r--openstackclient/tests/functional/volume/v1/test_snapshot.py109
1 files changed, 60 insertions, 49 deletions
diff --git a/openstackclient/tests/functional/volume/v1/test_snapshot.py b/openstackclient/tests/functional/volume/v1/test_snapshot.py
index 5a76a2e9..c8c956d1 100644
--- a/openstackclient/tests/functional/volume/v1/test_snapshot.py
+++ b/openstackclient/tests/functional/volume/v1/test_snapshot.py
@@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import uuid
from openstackclient.tests.functional.volume.v1 import common
@@ -25,11 +24,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
def setUpClass(cls):
super(VolumeSnapshotTests, cls).setUpClass()
# create a volume for all tests to create snapshot
- cmd_output = json.loads(cls.openstack(
- 'volume create -f json ' +
+ cmd_output = cls.openstack(
+ 'volume create ' +
'--size 1 ' +
- cls.VOLLY
- ))
+ cls.VOLLY,
+ parse_output=True,
+ )
cls.wait_for_status('volume', cls.VOLLY, 'available')
cls.VOLUME_ID = cmd_output['id']
@@ -45,22 +45,24 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
def test_volume_snapshot_delete(self):
"""Test create, delete multiple"""
name1 = uuid.uuid4().hex
- cmd_output = json.loads(self.openstack(
- 'volume snapshot create -f json ' +
+ cmd_output = self.openstack(
+ 'volume snapshot create ' +
name1 +
- ' --volume ' + self.VOLLY
- ))
+ ' --volume ' + self.VOLLY,
+ parse_output=True,
+ )
self.assertEqual(
name1,
cmd_output["display_name"],
)
name2 = uuid.uuid4().hex
- cmd_output = json.loads(self.openstack(
- 'volume snapshot create -f json ' +
+ cmd_output = self.openstack(
+ 'volume snapshot create ' +
name2 +
- ' --volume ' + self.VOLLY
- ))
+ ' --volume ' + self.VOLLY,
+ parse_output=True,
+ )
self.assertEqual(
name2,
cmd_output["display_name"],
@@ -78,11 +80,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
def test_volume_snapshot_list(self):
"""Test create, list filter"""
name1 = uuid.uuid4().hex
- cmd_output = json.loads(self.openstack(
- 'volume snapshot create -f json ' +
+ cmd_output = self.openstack(
+ 'volume snapshot create ' +
name1 +
- ' --volume ' + self.VOLLY
- ))
+ ' --volume ' + self.VOLLY,
+ parse_output=True,
+ )
self.addCleanup(self.wait_for_delete, 'volume snapshot', name1)
self.addCleanup(self.openstack, 'volume snapshot delete ' + name1)
self.assertEqual(
@@ -100,11 +103,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
self.wait_for_status('volume snapshot', name1, 'available')
name2 = uuid.uuid4().hex
- cmd_output = json.loads(self.openstack(
- 'volume snapshot create -f json ' +
+ cmd_output = self.openstack(
+ 'volume snapshot create ' +
name2 +
- ' --volume ' + self.VOLLY
- ))
+ ' --volume ' + self.VOLLY,
+ parse_output=True,
+ )
self.addCleanup(self.wait_for_delete, 'volume snapshot', name2)
self.addCleanup(self.openstack, 'volume snapshot delete ' + name2)
self.assertEqual(
@@ -122,29 +126,32 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
self.wait_for_status('volume snapshot', name2, 'available')
# Test list --long, --status
- cmd_output = json.loads(self.openstack(
- 'volume snapshot list -f json ' +
+ cmd_output = self.openstack(
+ 'volume snapshot list ' +
'--long ' +
- '--status error'
- ))
+ '--status error',
+ parse_output=True,
+ )
names = [x["Name"] for x in cmd_output]
self.assertNotIn(name1, names)
self.assertNotIn(name2, names)
# Test list --volume
- cmd_output = json.loads(self.openstack(
- 'volume snapshot list -f json ' +
- '--volume ' + self.VOLLY
- ))
+ cmd_output = self.openstack(
+ 'volume snapshot list ' +
+ '--volume ' + self.VOLLY,
+ parse_output=True,
+ )
names = [x["Name"] for x in cmd_output]
self.assertIn(name1, names)
self.assertIn(name2, names)
# Test list --name
- cmd_output = json.loads(self.openstack(
- 'volume snapshot list -f json ' +
- '--name ' + name1
- ))
+ cmd_output = self.openstack(
+ 'volume snapshot list ' +
+ '--name ' + name1,
+ parse_output=True,
+ )
names = [x["Name"] for x in cmd_output]
self.assertIn(name1, names)
self.assertNotIn(name2, names)
@@ -153,12 +160,13 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
"""Test create, set, unset, show, delete volume snapshot"""
name = uuid.uuid4().hex
new_name = name + "_"
- cmd_output = json.loads(self.openstack(
- 'volume snapshot create -f json ' +
+ cmd_output = self.openstack(
+ 'volume snapshot create ' +
'--volume ' + self.VOLLY +
' --description aaaa ' +
- name
- ))
+ name,
+ parse_output=True,
+ )
self.addCleanup(self.wait_for_delete, 'volume snapshot', new_name)
self.addCleanup(self.openstack, 'volume snapshot delete ' + new_name)
self.assertEqual(
@@ -187,10 +195,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
self.assertOutput('', raw_output)
# Show snapshot set result
- cmd_output = json.loads(self.openstack(
- 'volume snapshot show -f json ' +
- new_name
- ))
+ cmd_output = self.openstack(
+ 'volume snapshot show ' +
+ new_name,
+ parse_output=True,
+ )
self.assertEqual(
new_name,
cmd_output["display_name"],
@@ -216,10 +225,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
)
self.assertOutput('', raw_output)
- cmd_output = json.loads(self.openstack(
- 'volume snapshot show -f json ' +
- new_name
- ))
+ cmd_output = self.openstack(
+ 'volume snapshot show ' +
+ new_name,
+ parse_output=True,
+ )
self.assertEqual(
{'Beta': 'b'},
cmd_output["properties"],
@@ -232,8 +242,9 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
new_name,
)
self.assertOutput('', raw_output)
- cmd_output = json.loads(self.openstack(
- 'volume snapshot show -f json ' +
- new_name
- ))
+ cmd_output = self.openstack(
+ 'volume snapshot show ' +
+ new_name,
+ parse_output=True,
+ )
self.assertEqual({}, cmd_output["properties"])