From e87ec8d9949a2307afd96312de4805fa9672bb1c Mon Sep 17 00:00:00 2001 From: Kendall Nelson Date: Tue, 13 Sep 2016 11:41:28 -0500 Subject: [PATCH] Fix coerce good values in test_fields.py In another patch, working on making Volume Attach Status into an enum, it was pointed out that the way values were being tested. This patch goes back and fixes how the other status fields are coercing good values. Change-Id: I33c0308ac97a31c3907af3c459eb0cb55e2d7a51 --- cinder/tests/unit/objects/test_fields.py | 47 +++++++++++++----------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/cinder/tests/unit/objects/test_fields.py b/cinder/tests/unit/objects/test_fields.py index 1fe018010..82fd41ca5 100644 --- a/cinder/tests/unit/objects/test_fields.py +++ b/cinder/tests/unit/objects/test_fields.py @@ -66,13 +66,16 @@ class TestBackupStatus(TestField): def setUp(self): super(TestBackupStatus, self).setUp() self.field = fields.BackupStatusField() - self.coerce_good_values = [('error', 'error'), - ('error_deleting', 'error_deleting'), - ('creating', 'creating'), - ('available', 'available'), - ('deleting', 'deleting'), - ('deleted', 'deleted'), - ('restoring', 'restoring')] + self.coerce_good_values = [('error', fields.BackupStatus.ERROR), + ('error_deleting', + fields.BackupStatus.ERROR_DELETING), + ('creating', fields.BackupStatus.CREATING), + ('available', + fields.BackupStatus.AVAILABLE), + ('deleting', fields.BackupStatus.DELETING), + ('deleted', fields.BackupStatus.DELETED), + ('restoring', + fields.BackupStatus.RESTORING)] self.coerce_bad_values = ['acme'] self.to_primitive_values = self.coerce_good_values[0:1] self.from_primitive_values = self.coerce_good_values[0:1] @@ -88,13 +91,14 @@ class TestConsistencyGroupStatus(TestField): def setUp(self): super(TestConsistencyGroupStatus, self).setUp() self.field = fields.ConsistencyGroupStatusField() - self.coerce_good_values = [('error', 'error'), - ('available', 'available'), - ('creating', 'creating'), - ('deleting', 'deleting'), - ('deleted', 'deleted'), - ('updating', 'updating'), - ('error_deleting', 'error_deleting')] + self.coerce_good_values = [ + ('error', fields.ConsistencyGroupStatus.ERROR), + ('available', fields.ConsistencyGroupStatus.AVAILABLE), + ('creating', fields.ConsistencyGroupStatus.CREATING), + ('deleting', fields.ConsistencyGroupStatus.DELETING), + ('deleted', fields.ConsistencyGroupStatus.DELETED), + ('updating', fields.ConsistencyGroupStatus.UPDATING), + ('error_deleting', fields.ConsistencyGroupStatus.ERROR_DELETING)] self.coerce_bad_values = ['acme'] self.to_primitive_values = self.coerce_good_values[0:1] self.from_primitive_values = self.coerce_good_values[0:1] @@ -110,13 +114,14 @@ class TestSnapshotStatus(TestField): def setUp(self): super(TestSnapshotStatus, self).setUp() self.field = fields.SnapshotStatusField() - self.coerce_good_values = [('error', 'error'), - ('available', 'available'), - ('creating', 'creating'), - ('deleting', 'deleting'), - ('deleted', 'deleted'), - ('updating', 'updating'), - ('error_deleting', 'error_deleting')] + self.coerce_good_values = [ + ('error', fields.SnapshotStatus.ERROR), + ('available', fields.SnapshotStatus.AVAILABLE), + ('creating', fields.SnapshotStatus.CREATING), + ('deleting', fields.SnapshotStatus.DELETING), + ('deleted', fields.SnapshotStatus.DELETED), + ('updating', fields.SnapshotStatus.UPDATING), + ('error_deleting', fields.SnapshotStatus.ERROR_DELETING)] self.coerce_bad_values = ['acme'] self.to_primitive_values = self.coerce_good_values[0:1] self.from_primitive_values = self.coerce_good_values[0:1]