From 94c7b1713a8eedd69a72c64aa6c8296b5c6aed85 Mon Sep 17 00:00:00 2001 From: John Davis Date: Tue, 16 Apr 2024 17:54:32 -0400 Subject: [PATCH] Add test_history_update --- test/unit/data/db/conftest.py | 2 ++ test/unit/data/db/test_misc.py | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/test/unit/data/db/conftest.py b/test/unit/data/db/conftest.py index 6bc44e10ad83..d8b5d0b09d1b 100644 --- a/test/unit/data/db/conftest.py +++ b/test/unit/data/db/conftest.py @@ -11,6 +11,7 @@ from galaxy import model as m from galaxy.datatypes.registry import Registry as DatatypesRegistry +from galaxy.model.triggers.update_audit_table import install as install_timestamp_triggers from . import MockObjectStore # utility fixtures @@ -38,6 +39,7 @@ def setup(engine): datatypes_registry = DatatypesRegistry() datatypes_registry.load_datatypes() m.set_datatypes_registry(datatypes_registry) + install_timestamp_triggers(engine) @pytest.fixture(autouse=True) diff --git a/test/unit/data/db/test_misc.py b/test/unit/data/db/test_misc.py index a5f310813c0b..b8ef3fe5cf0c 100644 --- a/test/unit/data/db/test_misc.py +++ b/test/unit/data/db/test_misc.py @@ -2,7 +2,6 @@ import pytest from sqlalchemy import inspect -from sqlalchemy.exc import IntegrityError from galaxy import model as m from galaxy.model.unittest_utils.db_helpers import get_hdca_by_name @@ -12,6 +11,34 @@ ) +def test_history_update(make_history, make_hda, session): + """ + Verify the following behavior: + - history updated due to hda insert + - history updated due to hda update + - history NOT updated when hda copied + """ + h1 = make_history() + old_update_time = h1.update_time + + hda = make_hda(history=h1, create_dataset=True, sa_session=session) + # history updated due to hda insert + assert h1.update_time > old_update_time + + old_update_time = h1.update_time + hda.name = "new name" + session.add(hda) + session.commit() + # history updated due to hda update + assert h1.update_time > old_update_time + + old_update_time = h1.update_time + hda2 = hda.copy() + assert hda2 + # history NOT updated when hda copied + assert h1.update_time == old_update_time + + def test_ratings( make_user, make_stored_workflow,