Merge "Allow None values to be returned from the API"
This commit is contained in:
commit
038cf5403e
@ -45,7 +45,7 @@ class Schema(object):
|
||||
def filter(self, obj):
|
||||
filtered = {}
|
||||
for key, value in six.iteritems(obj):
|
||||
if self._filter_func(self.properties, key) and value is not None:
|
||||
if self._filter_func(self.properties, key):
|
||||
filtered[key] = value
|
||||
return filtered
|
||||
|
||||
|
@ -132,6 +132,9 @@ class TestImages(functional.FunctionalTest):
|
||||
u'disk_format',
|
||||
u'container_format',
|
||||
u'owner',
|
||||
u'checksum',
|
||||
u'size',
|
||||
u'virtual_size',
|
||||
])
|
||||
self.assertEqual(checked_keys, set(image.keys()))
|
||||
expected_image = {
|
||||
@ -192,6 +195,9 @@ class TestImages(functional.FunctionalTest):
|
||||
u'disk_format',
|
||||
u'container_format',
|
||||
u'owner',
|
||||
u'checksum',
|
||||
u'size',
|
||||
u'virtual_size',
|
||||
])
|
||||
self.assertEqual(checked_keys, set(image.keys()))
|
||||
expected_image = {
|
||||
@ -279,9 +285,9 @@ class TestImages(functional.FunctionalTest):
|
||||
self.assertEqual(200, response.status_code)
|
||||
image = jsonutils.loads(response.text)
|
||||
self.assertEqual(image_id, image['id'])
|
||||
self.assertFalse('checksum' in image)
|
||||
self.assertNotIn('size', image)
|
||||
self.assertNotIn('virtual_size', image)
|
||||
self.assertIsNone(image['checksum'])
|
||||
self.assertIsNone(image['size'])
|
||||
self.assertIsNone(image['virtual_size'])
|
||||
self.assertEqual('bar', image['foo'])
|
||||
self.assertFalse(image['protected'])
|
||||
self.assertEqual('kernel', image['type'])
|
||||
@ -456,8 +462,8 @@ class TestImages(functional.FunctionalTest):
|
||||
response = requests.patch(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code, response.text)
|
||||
image = jsonutils.loads(response.text)
|
||||
self.assertNotIn('size', image)
|
||||
self.assertNotIn('virtual_size', image)
|
||||
self.assertIsNone(image['size'])
|
||||
self.assertIsNone(image['virtual_size'])
|
||||
self.assertEqual('queued', image['status'])
|
||||
|
||||
# Deletion should work. Deleting image-1
|
||||
@ -2111,8 +2117,8 @@ class TestImages(functional.FunctionalTest):
|
||||
image = jsonutils.loads(response.text)
|
||||
image_id = image['id']
|
||||
self.assertEqual('queued', image['status'])
|
||||
self.assertNotIn('size', image)
|
||||
self.assertNotIn('virtual_size', image)
|
||||
self.assertIsNone(image['size'])
|
||||
self.assertIsNone(image['virtual_size'])
|
||||
|
||||
file_path = os.path.join(self.test_dir, 'fake_image')
|
||||
with open(file_path, 'w') as fap:
|
||||
|
@ -92,6 +92,7 @@ class TestTasks(functional.FunctionalTest):
|
||||
u'self',
|
||||
u'status',
|
||||
u'type',
|
||||
u'result',
|
||||
u'updated_at'])
|
||||
self.assertEqual(checked_keys, set(task.keys()))
|
||||
expected_task = {
|
||||
|
@ -2743,6 +2743,16 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
||||
'self': '/v2/images/%s' % UUID2,
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'size': None,
|
||||
'name': None,
|
||||
'owner': None,
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'checksum': None,
|
||||
'disk_format': None,
|
||||
'virtual_size': None,
|
||||
'container_format': None,
|
||||
|
||||
},
|
||||
],
|
||||
'first': '/v2/images',
|
||||
@ -2847,6 +2857,15 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
||||
'self': '/v2/images/%s' % UUID2,
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'size': None,
|
||||
'name': None,
|
||||
'owner': None,
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'checksum': None,
|
||||
'disk_format': None,
|
||||
'virtual_size': None,
|
||||
'container_format': None,
|
||||
}
|
||||
response = webob.Response()
|
||||
self.serializer.show(response, self.fixtures[1])
|
||||
@ -3113,6 +3132,10 @@ class TestImagesSerializerWithExtendedSchema(test_utils.BaseTestCase):
|
||||
'self': '/v2/images/%s' % UUID2,
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'disk_format': None,
|
||||
'container_format': None,
|
||||
}
|
||||
response = webob.Response()
|
||||
self.serializer.show(response, self.fixture)
|
||||
@ -3137,6 +3160,10 @@ class TestImagesSerializerWithExtendedSchema(test_utils.BaseTestCase):
|
||||
'self': '/v2/images/%s' % UUID2,
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'disk_format': None,
|
||||
'container_format': None,
|
||||
}
|
||||
response = webob.Response()
|
||||
self.serializer.show(response, self.fixture)
|
||||
@ -3173,6 +3200,10 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'owner': '2c014f32-55eb-467d-8fcb-4bd706012f81',
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'disk_format': None,
|
||||
'container_format': None,
|
||||
}
|
||||
response = webob.Response()
|
||||
serializer.show(response, self.fixture)
|
||||
@ -3203,6 +3234,10 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'owner': '2c014f32-55eb-467d-8fcb-4bd706012f81',
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'disk_format': None,
|
||||
'container_format': None,
|
||||
}
|
||||
response = webob.Response()
|
||||
serializer.show(response, self.fixture)
|
||||
@ -3227,6 +3262,10 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
|
||||
'self': '/v2/images/%s' % UUID2,
|
||||
'file': '/v2/images/%s/file' % UUID2,
|
||||
'schema': '/v2/schemas/image',
|
||||
'min_ram': None,
|
||||
'min_disk': None,
|
||||
'disk_format': None,
|
||||
'container_format': None,
|
||||
}
|
||||
response = webob.Response()
|
||||
serializer.show(response, self.fixture)
|
||||
|
Loading…
x
Reference in New Issue
Block a user