Fix Metadef Object update issue with python-glanceclient
Disallowed fields(schema, created_at and updated_at) were getting deleted from Metadef namespace instead of Metadef object. Change-Id: Id80e204c7af1ac6926c66627d290a15c4e6b00d9 Closes-Bug: #1433884
This commit is contained in:
parent
9c172fb056
commit
5d933b0dd5
@ -664,6 +664,14 @@ class TestNamespaceController(testtools.TestCase):
|
|||||||
self.assertRaises(TypeError, self.controller.update, NAMESPACE1,
|
self.assertRaises(TypeError, self.controller.update, NAMESPACE1,
|
||||||
**properties)
|
**properties)
|
||||||
|
|
||||||
|
def test_update_namespace_disallowed_fields(self):
|
||||||
|
properties = {'display_name': 'My Updated Name'}
|
||||||
|
self.controller.update(NAMESPACE1, **properties)
|
||||||
|
actual = self.api.calls
|
||||||
|
_disallowed_fields = ['self', 'schema', 'created_at', 'updated_at']
|
||||||
|
for key in actual[1][3]:
|
||||||
|
self.assertNotIn(key, _disallowed_fields)
|
||||||
|
|
||||||
def test_delete_namespace(self):
|
def test_delete_namespace(self):
|
||||||
self.controller.delete(NAMESPACE1)
|
self.controller.delete(NAMESPACE1)
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -304,6 +304,24 @@ class TestObjectController(testtools.TestCase):
|
|||||||
self.assertRaises(TypeError, self.controller.update, NAMESPACE1,
|
self.assertRaises(TypeError, self.controller.update, NAMESPACE1,
|
||||||
OBJECT1, **properties)
|
OBJECT1, **properties)
|
||||||
|
|
||||||
|
def test_update_object_disallowed_fields(self):
|
||||||
|
properties = {
|
||||||
|
'description': 'UPDATED_DESCRIPTION'
|
||||||
|
}
|
||||||
|
self.controller.update(NAMESPACE1, OBJECT1, **properties)
|
||||||
|
actual = self.api.calls
|
||||||
|
# API makes three calls(GET, PUT, GET) for object update.
|
||||||
|
# PUT has the request body in the list
|
||||||
|
'''('PUT', '/v2/metadefs/namespaces/Namespace1/objects/Object1', {},
|
||||||
|
[('description', 'UPDATED_DESCRIPTION'),
|
||||||
|
('name', 'Object1'),
|
||||||
|
('properties', ...),
|
||||||
|
('required', [])])'''
|
||||||
|
|
||||||
|
_disallowed_fields = ['self', 'schema', 'created_at', 'updated_at']
|
||||||
|
for key in actual[1][3]:
|
||||||
|
self.assertNotIn(key, _disallowed_fields)
|
||||||
|
|
||||||
def test_delete_object(self):
|
def test_delete_object(self):
|
||||||
self.controller.delete(NAMESPACE1, OBJECT1)
|
self.controller.delete(NAMESPACE1, OBJECT1)
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -280,6 +280,16 @@ class TestPropertyController(testtools.TestCase):
|
|||||||
self.assertRaises(TypeError, self.controller.update, NAMESPACE1,
|
self.assertRaises(TypeError, self.controller.update, NAMESPACE1,
|
||||||
PROPERTY1, **properties)
|
PROPERTY1, **properties)
|
||||||
|
|
||||||
|
def test_update_property_disallowed_fields(self):
|
||||||
|
properties = {
|
||||||
|
'description': 'UPDATED_DESCRIPTION'
|
||||||
|
}
|
||||||
|
self.controller.update(NAMESPACE1, PROPERTY1, **properties)
|
||||||
|
actual = self.api.calls
|
||||||
|
_disallowed_fields = ['created_at', 'updated_at']
|
||||||
|
for key in actual[1][3]:
|
||||||
|
self.assertNotIn(key, _disallowed_fields)
|
||||||
|
|
||||||
def test_delete_property(self):
|
def test_delete_property(self):
|
||||||
self.controller.delete(NAMESPACE1, PROPERTY1)
|
self.controller.delete(NAMESPACE1, PROPERTY1)
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -348,8 +348,8 @@ class ObjectController(object):
|
|||||||
# Remove read-only parameters.
|
# Remove read-only parameters.
|
||||||
read_only = ['schema', 'updated_at', 'created_at']
|
read_only = ['schema', 'updated_at', 'created_at']
|
||||||
for elem in read_only:
|
for elem in read_only:
|
||||||
if elem in namespace:
|
if elem in obj:
|
||||||
del namespace[elem]
|
del obj[elem]
|
||||||
|
|
||||||
url = '/v2/metadefs/namespaces/{0}/objects/{1}'.format(namespace,
|
url = '/v2/metadefs/namespaces/{0}/objects/{1}'.format(namespace,
|
||||||
object_name)
|
object_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user