diff --git a/glance/artifacts/updater.py b/glance/artifacts/updater.py index 61a9a9f0..9e3fccc5 100644 --- a/glance/artifacts/updater.py +++ b/glance/artifacts/updater.py @@ -37,6 +37,7 @@ class ArtifactProxy(proxy.Artifact): path = kwargs.get("path") value = kwargs.get("value") prop_name, delimiter, path_left = path.lstrip('/').partition('/') + super(ArtifactProxy, self).get_type_specific_property(prop_name) if not path_left: return setattr(self, prop_name, value) try: diff --git a/glance/tests/functional/artifacts/test_artifacts.py b/glance/tests/functional/artifacts/test_artifacts.py index 7415224d..9183c888 100644 --- a/glance/tests/functional/artifacts/test_artifacts.py +++ b/glance/tests/functional/artifacts/test_artifacts.py @@ -491,6 +491,81 @@ paste.filter_factory = glance.tests.utils:FakeAuthMiddleware.factory data='ZZZZZ', status=200) self._check_artifact_delete('/withblob/v1/%s' % art['id']) + def test_update_nonexistent_property_by_replace_op(self): + art = self._create_artifact('withprops', data={'name': 'some art', + 'version': '4.2'}) + data = [{'op': 'replace', 'value': 'some value', + 'path': '/nonexistent_property'}] + result = self._check_artifact_patch('/withprops/v1/%s' % + art['id'], + data=data, + status=400) + actual = u'''\ + + + 400 Bad Request + + +

400 Bad Request

+ Artifact has no property nonexistent_property

+ + + + +''' + + self.assertEqual(actual, result) + + def test_update_nonexistent_property_by_remove_op(self): + art = self._create_artifact('withprops', data={'name': 'some art', + 'version': '4.2'}) + data = [{'op': 'replace', 'value': 'some value', + 'path': '/nonexistent_property'}] + result = self._check_artifact_patch('/withprops/v1/%s' % + art['id'], + data=data, + status=400) + actual = u'''\ + + + 400 Bad Request + + +

400 Bad Request

+ Artifact has no property nonexistent_property

+ + + + +''' + + self.assertEqual(actual, result) + + def test_update_nonexistent_property_by_add_op(self): + art = self._create_artifact('withprops', data={'name': 'some art', + 'version': '4.2'}) + data = [{'op': 'replace', 'value': 'some value', + 'path': '/nonexistent_property'}] + result = self._check_artifact_patch('/withprops/v1/%s' % + art['id'], + data=data, + status=400) + actual = u'''\ + + + 400 Bad Request + + +

400 Bad Request

+ Artifact has no property nonexistent_property

+ + + + +''' + + self.assertEqual(actual, result) + def test_update_array_property_by_replace_op(self): art = self._create_artifact('withprops', data={'name': 'some art', 'version': '4.2'})