Copy the size of the tag set
As the tags are being removed it can cause the removal of the current tag when running tests. Causing a RuntimeError to be thrown. This change makes a temporary list whilst the tags are being deleted. Co-Authored-By: Tom Cocozzello <tjcocozz@us.ibm.com> Change-Id: I3cac9060b87449503fba3995d10f8d4e074bffb8 Closes-Bug: 1555275
This commit is contained in:
parent
a65ea64bac
commit
def8cfdeef
|
@ -784,7 +784,7 @@ def image_tag_get(context, image_id, value):
|
|||
@log_call
|
||||
def image_tag_set_all(context, image_id, values):
|
||||
global DATA
|
||||
DATA['tags'][image_id] = values
|
||||
DATA['tags'][image_id] = list(values)
|
||||
|
||||
|
||||
@log_call
|
||||
|
|
|
@ -1909,6 +1909,32 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual('deleted', deleted_img['status'])
|
||||
self.assertNotIn('%s/%s' % (BASE_URI, UUID1), self.store.data)
|
||||
|
||||
def test_delete_with_tags(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
changes = [
|
||||
{'op': 'replace', 'path': ['tags'],
|
||||
'value': ['many', 'cool', 'new', 'tags']},
|
||||
]
|
||||
self.controller.update(request, UUID1, changes)
|
||||
self.assertIn('%s/%s' % (BASE_URI, UUID1), self.store.data)
|
||||
self.controller.delete(request, UUID1)
|
||||
output_logs = self.notifier.get_logs()
|
||||
|
||||
# Get `delete` event from logs
|
||||
output_delete_logs = [output_log for output_log in output_logs
|
||||
if output_log['event_type'] == 'image.delete']
|
||||
|
||||
self.assertEqual(1, len(output_delete_logs))
|
||||
output_log = output_delete_logs[0]
|
||||
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
|
||||
deleted_img = self.db.image_get(request.context, UUID1,
|
||||
force_show_deleted=True)
|
||||
self.assertTrue(deleted_img['deleted'])
|
||||
self.assertEqual('deleted', deleted_img['status'])
|
||||
self.assertNotIn('%s/%s' % (BASE_URI, UUID1), self.store.data)
|
||||
|
||||
def test_delete_disabled_notification(self):
|
||||
self.config(disabled_notifications=["image.delete"])
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
|
Loading…
Reference in New Issue