From cea780cbf804cd1e4bdb36599f74cd1f7cdd2641 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 16 Feb 2022 11:36:06 +0100 Subject: [PATCH 1/3] Test that include_hidden is handled correctly --- test/unit/test_model_store.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/test/unit/test_model_store.py b/test/unit/test_model_store.py index 58fd0d5d2ce..f075fcd7ea8 100644 --- a/test/unit/test_model_store.py +++ b/test/unit/test_model_store.py @@ -32,6 +32,30 @@ def test_import_export_history_failed_job(): _assert_simple_cat_job_imported(imported_history, state='error') +def test_import_export_history_hidden_false_with_hidden_dataset(): + app = _mock_app() + + u, h, d1, d2, j = _setup_simple_cat_job(app) + d2.visible = False + app.model.session.flush() + + imported_history = _import_export_history(app, h, export_files="copy", include_hidden=False) + assert d2.dataset.get_size() > 0 + assert imported_history.datasets[-1].get_size() == 0 + + +def test_import_export_history_hidden_true_with_hidden_dataset(): + app = _mock_app() + + u, h, d1, d2, j = _setup_simple_cat_job(app) + d2.visible = False + app.model.session.flush() + + imported_history = _import_export_history(app, h, export_files="copy", include_hidden=True) + assert d2.dataset.get_size() > 0 + assert imported_history.datasets[-1].get_size() > 0 + + def test_import_export_bag_archive(): """Test a simple job import/export using a BagIt archive.""" dest_parent = mkdtemp() @@ -460,13 +484,13 @@ def _setup_simple_cat_job(app, state='ok'): return u, h, d1, d2, j -def _import_export_history(app, h, dest_export=None, export_files=None): +def _import_export_history(app, h, dest_export=None, export_files=None, include_hidden=False): if dest_export is None: dest_parent = mkdtemp() dest_export = os.path.join(dest_parent, "moo.tgz") with store.TarModelExportStore(dest_export, app=app, export_files=export_files) as export_store: - export_store.export_history(h) + export_store.export_history(h, include_hidden=include_hidden) imported_history = import_archive(dest_export, app, h.user) assert imported_history From baed73d3111cc6da4929616f44f479f41dcb0569 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 16 Feb 2022 11:38:36 +0100 Subject: [PATCH 2/3] Fix history_export include_hidden=False handling Fixes https://github.com/galaxyproject/galaxy/issues/13386 --- lib/galaxy/model/store/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/model/store/__init__.py b/lib/galaxy/model/store/__init__.py index dd580755442..d2c1c323c50 100644 --- a/lib/galaxy/model/store/__init__.py +++ b/lib/galaxy/model/store/__init__.py @@ -1142,7 +1142,7 @@ class DirectoryModelExportStore(ModelExportStore): datasets = query.all() for dataset in datasets: dataset.annotation = get_item_annotation_str(sa_session, history.user, dataset) - add_dataset = (not dataset.visible or not include_hidden) and (not dataset.deleted or include_deleted) + add_dataset = (dataset.visible or include_hidden) and (not dataset.deleted or include_deleted) if dataset.id in self.collection_datasets: add_dataset = True From c58f44314d6261c51668bc924e00115b2177507f Mon Sep 17 00:00:00 2001 From: Marius van den Beek Date: Wed, 16 Feb 2022 16:00:06 +0100 Subject: [PATCH 3/3] Make test assertions more precise Co-authored-by: Nicola Soranzo --- test/unit/test_model_store.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/test_model_store.py b/test/unit/test_model_store.py index f075fcd7ea8..5b4fe1303eb 100644 --- a/test/unit/test_model_store.py +++ b/test/unit/test_model_store.py @@ -40,8 +40,8 @@ def test_import_export_history_hidden_false_with_hidden_dataset(): app.model.session.flush() imported_history = _import_export_history(app, h, export_files="copy", include_hidden=False) - assert d2.dataset.get_size() > 0 - assert imported_history.datasets[-1].get_size() == 0 + assert d1.dataset.get_size() == imported_history.datasets[0].get_size() + assert imported_history.datasets[1].get_size() == 0 def test_import_export_history_hidden_true_with_hidden_dataset(): @@ -52,8 +52,8 @@ def test_import_export_history_hidden_true_with_hidden_dataset(): app.model.session.flush() imported_history = _import_export_history(app, h, export_files="copy", include_hidden=True) - assert d2.dataset.get_size() > 0 - assert imported_history.datasets[-1].get_size() > 0 + assert d1.dataset.get_size() == imported_history.datasets[0].get_size() + assert d2.dataset.get_size() == imported_history.datasets[1].get_size() def test_import_export_bag_archive():