Commit 2b27e82b authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added transaction back to repository db tests.

parent c1be7695
Pipeline #44806 passed with stages
in 25 minutes and 7 seconds
...@@ -222,6 +222,9 @@ def create_postgres_infra(monkeysession=None, **kwargs): ...@@ -222,6 +222,9 @@ def create_postgres_infra(monkeysession=None, **kwargs):
connection, _ = infrastructure.sqlalchemy_repository_db(**db_args) connection, _ = infrastructure.sqlalchemy_repository_db(**db_args)
assert connection is not None assert connection is not None
# we use a transaction around the session to rollback anything that happens within
# test execution
trans = connection.begin()
db = Session(bind=connection, autocommit=True) db = Session(bind=connection, autocommit=True)
old_connection, old_db = None, None old_connection, old_db = None, None
...@@ -238,6 +241,7 @@ def create_postgres_infra(monkeysession=None, **kwargs): ...@@ -238,6 +241,7 @@ def create_postgres_infra(monkeysession=None, **kwargs):
monkeysession.setattr('nomad.infrastructure.repository_db', old_db) monkeysession.setattr('nomad.infrastructure.repository_db', old_db)
monkeysession.setattr('nomad.config.repository_db', old_config) monkeysession.setattr('nomad.config.repository_db', old_config)
trans.rollback()
db.expunge_all() db.expunge_all()
db.invalidate() db.invalidate()
db.close_all() db.close_all()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment