diff options
author | rabi <ramishra@redhat.com> | 2022-06-27 21:50:45 +0530 |
---|---|---|
committer | rabi <ramishra@redhat.com> | 2022-06-27 22:41:52 +0530 |
commit | 38238b88f74983534215bd4c0afdfd67fdbeaaa4 (patch) | |
tree | a004906547d07f5e161e91cded64ebf52ba3e6e7 | |
parent | c37ea72a6b2c424136ed2ee2cd378928021da78e (diff) | |
download | heat-38238b88f74983534215bd4c0afdfd67fdbeaaa4.tar.gz |
Fix tests for fixtures 4.0.0
This fixes ForeignKeyConstraintFixture for the db
tests. Also drops install_command from tox.ini.
Change-Id: I3d0abf68cae89566f4d346cd16919a6050168130
-rw-r--r-- | heat/tests/utils.py | 18 | ||||
-rw-r--r-- | tox.ini | 2 |
2 files changed, 12 insertions, 8 deletions
diff --git a/heat/tests/utils.py b/heat/tests/utils.py index cf3e383f8..19fc1a06f 100644 --- a/heat/tests/utils.py +++ b/heat/tests/utils.py @@ -220,15 +220,19 @@ class JsonRepr(object): class ForeignKeyConstraintFixture(fixtures.Fixture): - def __init__(self, sqlite_fk=True): - self.enable_fkc = sqlite_fk - def _setUp(self): - new_context = db_api.db_context.make_new_manager() - new_context.configure(sqlite_fk=self.enable_fkc) + def __init__(self): + self.engine = get_engine() - self.useFixture(fixtures.MockPatchObject(db_api, '_facade', None)) - self.addCleanup(db_api.db_context.patch_factory(new_context._factory)) + def _setUp(self): + if self.engine.name == 'sqlite': + self.engine.execute("PRAGMA foreign_keys=ON") + + def disable_fks(): + with self.engine.connect() as conn: + conn.connection.rollback() + conn.execute("PRAGMA foreign_keys=OFF") + self.addCleanup(disable_fks) class AnyInstance(object): @@ -9,7 +9,6 @@ basepython = python3 setenv = VIRTUAL_ENV={envdir} PYTHONWARNINGS=default::DeprecationWarning OS_TEST_PATH=heat/tests -install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages} usedevelop = True deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt @@ -59,6 +58,7 @@ allowlist_externals = rm deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/requirements.txt -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/build |