diff --git a/test/unit/data/model/db/test_misc.py b/test/unit/data/model/db/test_misc.py index 9a4e5b230168..b8ef3fe5cf0c 100644 --- a/test/unit/data/model/db/test_misc.py +++ b/test/unit/data/model/db/test_misc.py @@ -11,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,