SQLAlchemy may asynchronously push models out of session cache in which
case we may receive DetachedInstanceError.
In the test case, instead of deepcopying models to compare, compare
each modified attribute independently.
This change also includes conversion from InstrumentedLists to regular
lists when converting model attributes to object fields. The fact that
we were returning InstrumentedLists was always an oversight but it
revealed itself after the modification of the test case that is the
core of this patch.
When converting object fields to db, convert Port's distributed_binding
None value to a empty list to reflect that the relationship of the Port
database model is a list. It was not an issue before the patch because
we were not comparing model attribute for equality but for in-equality
before, and so None was always != [].
Finally, this patch moves a bunch of TODOs to better reflect where they
belong to.
Reviewed: https:/ /review. openstack. org/568390 /git.openstack. org/cgit/ openstack/ neutron/ commit/ ?id=1a8a15f6309 a56087702a09740 41fa9850de4f62
Committed: https:/
Submitter: Zuul
Branch: master
commit 1a8a15f6309a560 87702a0974041fa 9850de4f62
Author: Ihar Hrachyshka <email address hidden>
Date: Mon May 14 21:57:52 2018 +0000
objects: avoid deepcopying models in test_db_obj
SQLAlchemy may asynchronously push models out of session cache in which eError.
case we may receive DetachedInstanc
In the test case, instead of deepcopying models to compare, compare
each modified attribute independently.
This change also includes conversion from InstrumentedLists to regular
lists when converting model attributes to object fields. The fact that
we were returning InstrumentedLists was always an oversight but it
revealed itself after the modification of the test case that is the
core of this patch.
When converting object fields to db, convert Port's distributed_binding
None value to a empty list to reflect that the relationship of the Port
database model is a list. It was not an issue before the patch because
we were not comparing model attribute for equality but for in-equality
before, and so None was always != [].
Finally, this patch moves a bunch of TODOs to better reflect where they
belong to.
Closes-Bug: #1770452 470ec1a59345db9 845a6198328
Change-Id: I42cdf540129bd4