mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix transaction error in unit test
In galaxy, HistoryAudit.prune() executes in the context of a separate thread, where it starts and commits a new transaction, closing a scoped session on exit. Thus, here we should end the current transaction (via rollback) and add the History objects to a new session, as the previous one will be closed.
This commit is contained in:
@@ -661,7 +661,7 @@ class TestMappings(BaseModelTestCase):
|
||||
|
||||
self.new_hda(h1, name="1")
|
||||
self.new_hda(h2, name="2")
|
||||
self.session().flush()
|
||||
self.session().commit()
|
||||
# _next_hid modifies history, plus trigger on HDA means 2 additional audit rows per history
|
||||
|
||||
h1_audits = get_audit_table_entries(h1)
|
||||
@@ -672,7 +672,13 @@ class TestMappings(BaseModelTestCase):
|
||||
h1_latest = get_latest_entry(h1_audits)
|
||||
h2_latest = get_latest_entry(h2_audits)
|
||||
|
||||
# In galaxy, HistoryAudit.prune() executes in the context of a separate thread, where it
|
||||
# starts and commits a new transaction, closing a scoped session on exit. Thus, here we
|
||||
# should end the current transaction (via rollback) and add the History objects to a new
|
||||
# session, as the previous one will be closed.
|
||||
self.session().rollback()
|
||||
model.HistoryAudit.prune(self.session())
|
||||
self.session().add_all([h1, h2])
|
||||
|
||||
h1_audits = get_audit_table_entries(h1)
|
||||
h2_audits = get_audit_table_entries(h2)
|
||||
|
||||
Reference in New Issue
Block a user