Revert "Don't update tags every time"
This reverts commit e77322c17931810f4029ef339a791f702f2f4580. Change-Id: Ida826a2aa888beeb76dbe657b2ccd6cb088157ed
This commit is contained in:
parent
e77322c179
commit
b78285761d
glanceclient
@ -381,20 +381,6 @@ data_fixtures = {
|
|||||||
'',
|
'',
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'/v2/images/a2b83adc-888e-11e3-8872-78acc0b951d9': {
|
|
||||||
'GET': (
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
'id': 'a2b83adc-888e-11e3-8872-78acc0b951d9',
|
|
||||||
'name': 'image-1',
|
|
||||||
'tags': ['tag1', 'tag2'],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
'PATCH': (
|
|
||||||
{},
|
|
||||||
'',
|
|
||||||
)
|
|
||||||
},
|
|
||||||
'/v2/images?limit=%d&os_distro=NixOS' % images.DEFAULT_PAGE_SIZE: {
|
'/v2/images?limit=%d&os_distro=NixOS' % images.DEFAULT_PAGE_SIZE: {
|
||||||
'GET': (
|
'GET': (
|
||||||
{},
|
{},
|
||||||
@ -996,23 +982,6 @@ class TestController(testtools.TestCase):
|
|||||||
# will not actually change - yet in real life it will...
|
# will not actually change - yet in real life it will...
|
||||||
self.assertEqual('image-3', image.name)
|
self.assertEqual('image-3', image.name)
|
||||||
|
|
||||||
def test_update_add_prop_with_tags(self):
|
|
||||||
image_id = 'a2b83adc-888e-11e3-8872-78acc0b951d9'
|
|
||||||
params = {'finn': 'human'}
|
|
||||||
image = self.controller.update(image_id, **params)
|
|
||||||
expect_hdrs = {
|
|
||||||
'Content-Type': 'application/openstack-images-v2.1-json-patch',
|
|
||||||
}
|
|
||||||
expect_body = [[('op', 'add'), ('path', '/finn'), ('value', 'human')]]
|
|
||||||
expect = [
|
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
|
||||||
('PATCH', '/v2/images/%s' % image_id, expect_hdrs, expect_body),
|
|
||||||
('GET', '/v2/images/%s' % image_id, {}, None),
|
|
||||||
]
|
|
||||||
self.assertEqual(expect, self.api.calls)
|
|
||||||
self.assertEqual(image_id, image.id)
|
|
||||||
self.assertEqual('image-1', image.name)
|
|
||||||
|
|
||||||
def test_update_bad_additionalProperty_type(self):
|
def test_update_bad_additionalProperty_type(self):
|
||||||
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
image_id = 'e7e59ff6-fa2e-4075-87d3-1a1398a07dc3'
|
||||||
params = {'name': 'pong', 'bad_prop': False}
|
params = {'name': 'pong', 'bad_prop': False}
|
||||||
|
@ -31,12 +31,12 @@ class SchemaBasedModel(warlock.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def _make_custom_patch(self, new, original):
|
def _make_custom_patch(self, new, original):
|
||||||
if 'tags' in new and 'tags' not in original:
|
if not self.get('tags'):
|
||||||
|
tags_patch = []
|
||||||
|
else:
|
||||||
tags_patch = [{"path": "/tags",
|
tags_patch = [{"path": "/tags",
|
||||||
"value": self.get('tags'),
|
"value": self.get('tags'),
|
||||||
"op": "replace"}]
|
"op": "replace"}]
|
||||||
else:
|
|
||||||
tags_patch = []
|
|
||||||
|
|
||||||
patch_string = jsonpatch.make_patch(original, new).to_string()
|
patch_string = jsonpatch.make_patch(original, new).to_string()
|
||||||
patch = json.loads(patch_string)
|
patch = json.loads(patch_string)
|
||||||
@ -55,6 +55,9 @@ class SchemaBasedModel(warlock.Model):
|
|||||||
if (name not in original and name in new and
|
if (name not in original and name in new and
|
||||||
prop.get('is_base', True)):
|
prop.get('is_base', True)):
|
||||||
original[name] = None
|
original[name] = None
|
||||||
|
|
||||||
|
original['tags'] = None
|
||||||
|
new['tags'] = None
|
||||||
return self._make_custom_patch(new, original)
|
return self._make_custom_patch(new, original)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user