Merge "Correct VolumeMigrationStatusField"

This commit is contained in:
Zuul 2022-07-06 18:04:28 +00:00 committed by Gerrit Code Review
commit cc3f475490
2 changed files with 30 additions and 1 deletions

View File

@ -213,7 +213,7 @@ class VolumeMigrationStatus(BaseCinderEnum):
class VolumeMigrationStatusField(BaseEnumField):
AUTO_TYPE = VolumeStatus()
AUTO_TYPE = VolumeMigrationStatus()
class DictOfNullableField(fields.AutoTypedField):

View File

@ -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')