Handle already created objects in "test_update_timpestamp"
In [1], if the waiting loop is executed more than once, the previously created objects should be deleted first to avoid the problem related in [2]. [1] https://review.opendev.org/#/c/678262 [2] https://bugs.launchpad.net/neutron/+bug/1841183/comments/3 Change-Id: I86cd17be6a776e4598abaeeb63de2eecbf0a64f9 Related-Bug: #1841183
This commit is contained in:
parent
4f6b8bb3e5
commit
560c56e603
@ -246,26 +246,35 @@ class TimeStampDBMixinTestCase(TimeStampChangedsinceTestCase):
|
||||
ctx = context.get_admin_context()
|
||||
obj = net_obj.Network(ctx, id=network_id)
|
||||
obj.create()
|
||||
return obj.standard_attr_id
|
||||
return obj
|
||||
|
||||
# Use tag as non StandardAttribute object
|
||||
def _save_tag(self, tags, standard_attr_id):
|
||||
ctx = context.get_admin_context()
|
||||
ret = []
|
||||
for tag in tags:
|
||||
tag_obj.Tag(ctx, standard_attr_id=standard_attr_id,
|
||||
tag=tag).create()
|
||||
_tag_obj = tag_obj.Tag(ctx, standard_attr_id=standard_attr_id,
|
||||
tag=tag)
|
||||
_tag_obj.create()
|
||||
ret.append(_tag_obj)
|
||||
return ret
|
||||
|
||||
def test_update_timpestamp(self):
|
||||
self._standard_attr_id = None
|
||||
self._network = None
|
||||
self._tags = []
|
||||
|
||||
def save_network():
|
||||
if self._network:
|
||||
self._network.delete()
|
||||
timenow.reset_mock()
|
||||
self._standard_attr_id = self._save_network(network_id)
|
||||
self._network = self._save_network(network_id)
|
||||
return 1 == timenow.call_count
|
||||
|
||||
def save_tag():
|
||||
for tag in self._tags:
|
||||
tag.delete()
|
||||
timenow.reset_mock()
|
||||
self._save_tag(tags, self._standard_attr_id)
|
||||
self._tags = self._save_tag(tags, self._network.standard_attr_id)
|
||||
return 0 == timenow.call_count
|
||||
|
||||
network_id = uuidutils.generate_uuid()
|
||||
|
Loading…
Reference in New Issue
Block a user