Skip to content

Commit

Permalink
Add test_history_update
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Apr 16, 2024
1 parent 768965b commit d5b0a9c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/unit/data/db/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 28 additions & 1 deletion test/unit/data/db/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit d5b0a9c

Please sign in to comment.