From be3a8279fbca166b80db4762a8c73b3cbea6a8fa Mon Sep 17 00:00:00 2001 From: Brian Rosmaita Date: Thu, 28 Apr 2022 17:35:01 -0400 Subject: [PATCH] Correct VolumeMigrationStatusField It's not currently being used anywhere and is probably only defined for symmetry, but it might as well be correct in case someone decides to use it. Change-Id: I6feb6b49df84f3f565d089ae55dee471fc1cf3e1 --- cinder/objects/fields.py | 2 +- cinder/tests/unit/objects/test_fields.py | 29 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cinder/objects/fields.py b/cinder/objects/fields.py index cee1c687bf2..3792647acde 100644 --- a/cinder/objects/fields.py +++ b/cinder/objects/fields.py @@ -213,7 +213,7 @@ class VolumeMigrationStatus(BaseCinderEnum): class VolumeMigrationStatusField(BaseEnumField): - AUTO_TYPE = VolumeStatus() + AUTO_TYPE = VolumeMigrationStatus() class DictOfNullableField(fields.AutoTypedField): diff --git a/cinder/tests/unit/objects/test_fields.py b/cinder/tests/unit/objects/test_fields.py index ac075ead9db..1a052f074e0 100644 --- a/cinder/tests/unit/objects/test_fields.py +++ b/cinder/tests/unit/objects/test_fields.py @@ -156,3 +156,32 @@ class TestVolumeAttachStatus(TestField): def test_stringify_invalid(self): self.assertRaises(ValueError, self.field.stringify, 'not_a_status') + + +class TestVolumeMigrationStatus(TestField): + def setUp(self): + super(TestVolumeMigrationStatus, self).setUp() + self.field = fields.VolumeMigrationStatusField() + self.coerce_good_values = [ + ('migrating', + fields.VolumeMigrationStatus.MIGRATING), + ('error', + fields.VolumeMigrationStatus.ERROR), + ('success', + fields.VolumeMigrationStatus.SUCCESS), + ('completing', + fields.VolumeMigrationStatus.COMPLETING), + ('starting', + fields.VolumeMigrationStatus.STARTING), + ('none', + fields.VolumeMigrationStatus.NONE), + ] + self.coerce_bad_values = ['available'] + self.to_primitive_values = self.coerce_good_values + self.from_primitive_values = self.coerce_good_values + + def test_stringify(self): + self.assertEqual("'migrating'", self.field.stringify('migrating')) + + def test_stringify_invalid(self): + self.assertRaises(ValueError, self.field.stringify, 'not_a_status')