Merge "Allow some fields to be None"

This commit is contained in:
Jenkins 2014-12-03 04:29:47 +00:00 committed by Gerrit Code Review
commit 3c3f85405a
2 changed files with 13 additions and 13 deletions

View File

@ -704,7 +704,7 @@ def get_base_properties():
'-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$'),
},
'name': {
'type': 'string',
'type': ['null', 'string'],
'description': _('Descriptive name for the image'),
'maxLength': 255,
},
@ -724,32 +724,32 @@ def get_base_properties():
'description': _('If true, image will not be deletable.'),
},
'checksum': {
'type': 'string',
'type': ['null', 'string'],
'description': _('md5 hash of image contents. (READ-ONLY)'),
'maxLength': 32,
},
'owner': {
'type': 'string',
'type': ['null', 'string'],
'description': _('Owner of the image'),
'maxLength': 255,
},
'size': {
'type': 'integer',
'type': ['null', 'integer'],
'description': _('Size of image file in bytes (READ-ONLY)'),
},
'virtual_size': {
'type': 'integer',
'type': ['null', 'integer'],
'description': _('Virtual size of image in bytes (READ-ONLY)'),
},
'container_format': {
'type': 'string',
'type': ['null', 'string'],
'description': _('Format of the container'),
'enum': CONF.image_format.container_formats,
'enum': [None] + CONF.image_format.container_formats,
},
'disk_format': {
'type': 'string',
'type': ['null', 'string'],
'description': _('Format of the disk'),
'enum': CONF.image_format.disk_formats,
'enum': [None] + CONF.image_format.disk_formats,
},
'created_at': {
'type': 'string',

View File

@ -3321,7 +3321,7 @@ class TestImagesSerializerDirectUrl(test_utils.BaseTestCase):
class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase):
def test_default_disk_formats(self):
schema = glance.api.v2.images.get_schema()
expected = ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2',
expected = [None, 'ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2',
'vdi', 'iso']
actual = schema.properties['disk_format']['enum']
self.assertEqual(expected, actual)
@ -3329,20 +3329,20 @@ class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase):
def test_custom_disk_formats(self):
self.config(disk_formats=['gabe'], group="image_format")
schema = glance.api.v2.images.get_schema()
expected = ['gabe']
expected = [None, 'gabe']
actual = schema.properties['disk_format']['enum']
self.assertEqual(expected, actual)
def test_default_container_formats(self):
schema = glance.api.v2.images.get_schema()
expected = ['ami', 'ari', 'aki', 'bare', 'ovf', 'ova']
expected = [None, 'ami', 'ari', 'aki', 'bare', 'ovf', 'ova']
actual = schema.properties['container_format']['enum']
self.assertEqual(expected, actual)
def test_custom_container_formats(self):
self.config(container_formats=['mark'], group="image_format")
schema = glance.api.v2.images.get_schema()
expected = ['mark']
expected = [None, 'mark']
actual = schema.properties['container_format']['enum']
self.assertEqual(expected, actual)