Merge "Add specific values to specific fields in get_random_object_fields()"
This commit is contained in:
commit
05e91d3888
@ -519,6 +519,7 @@ class _BaseObjectTestCase(object):
|
|||||||
objects.register_objects()
|
objects.register_objects()
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
self._unique_tracker = collections.defaultdict(set)
|
self._unique_tracker = collections.defaultdict(set)
|
||||||
|
self.locked_obj_fields = collections.defaultdict(set)
|
||||||
self.db_objs = [
|
self.db_objs = [
|
||||||
self._test_class.db_model(**self.get_random_db_fields())
|
self._test_class.db_model(**self.get_random_db_fields())
|
||||||
for _ in range(3)
|
for _ in range(3)
|
||||||
@ -562,6 +563,9 @@ class _BaseObjectTestCase(object):
|
|||||||
if field not in obj_cls.synthetic_fields:
|
if field not in obj_cls.synthetic_fields:
|
||||||
generator = FIELD_TYPE_VALUE_GENERATOR_MAP[type(field_obj)]
|
generator = FIELD_TYPE_VALUE_GENERATOR_MAP[type(field_obj)]
|
||||||
fields[field] = get_value(generator, ip_version)
|
fields[field] = get_value(generator, ip_version)
|
||||||
|
for k, v in self.locked_obj_fields.items():
|
||||||
|
if k in fields:
|
||||||
|
fields[k] = v
|
||||||
for keys in obj_cls.unique_keys:
|
for keys in obj_cls.unique_keys:
|
||||||
keytup = tuple(keys)
|
keytup = tuple(keys)
|
||||||
unique_values = tuple(fields[k] for k in keytup)
|
unique_values = tuple(fields[k] for k in keytup)
|
||||||
@ -611,6 +615,7 @@ class _BaseObjectTestCase(object):
|
|||||||
obj[k] = val
|
obj[k] = val
|
||||||
if k in self.valid_field_filter:
|
if k in self.valid_field_filter:
|
||||||
self.valid_field_filter[k] = val
|
self.valid_field_filter[k] = val
|
||||||
|
self.locked_obj_fields[k] = v() if callable(v) else v
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_object_keys(cls, obj_cls, field_names=None):
|
def generate_object_keys(cls, obj_cls, field_names=None):
|
||||||
|
@ -31,7 +31,7 @@ class RouterL3AgentBindingDbObjTestCase(test_base.BaseDbObjectTestCase,
|
|||||||
super(RouterL3AgentBindingDbObjTestCase, self).setUp()
|
super(RouterL3AgentBindingDbObjTestCase, self).setUp()
|
||||||
router_id = self._create_test_router_id()
|
router_id = self._create_test_router_id()
|
||||||
|
|
||||||
index = iter(range(1, len(self.objs) + 1))
|
index = iter(range(1, len(self.objs) + 2))
|
||||||
self.update_obj_fields(
|
self.update_obj_fields(
|
||||||
{'router_id': router_id,
|
{'router_id': router_id,
|
||||||
'binding_index': lambda: next(index),
|
'binding_index': lambda: next(index),
|
||||||
|
Loading…
Reference in New Issue
Block a user