Loading lib/galaxy_test/api/test_histories.py +30 −0 Original line number Diff line number Diff line Loading @@ -407,6 +407,36 @@ class TestHistoriesApi(ApiTestCase, BaseHistories): response = self.dataset_populator.tag_dataset(history_id, hda["id"], ["DatasetTag"], raise_on_error=False) assert response["err_msg"] == "History is immutable" def test_histories_count(self): # Create a new user so we can test the count without other existing histories with self._different_user("user_for_count@test.com"): first_history_id = self._create_history("TestHistoryForCount 1")["id"] self._assert_expected_histories_count(expected_count=1) second_history_id = self._create_history("TestHistoryForCount 2")["id"] self._assert_expected_histories_count(expected_count=2) third_history_id = self._create_history("TestHistoryForCount 3")["id"] self._assert_expected_histories_count(expected_count=3) # Delete the second history self.dataset_populator.delete_history(second_history_id) self._assert_expected_histories_count(expected_count=2) # Archive the first history self.dataset_populator.archive_history(first_history_id) self._assert_expected_histories_count(expected_count=1) # Only the third history should be active active_histories = self._get("histories").json() assert len(active_histories) == 1 assert active_histories[0]["id"] == third_history_id def _assert_expected_histories_count(self, expected_count): response = self._get("histories/count") self._assert_status_code_is(response, 200) assert response.json() == expected_count class ImportExportTests(BaseHistories): task_based: ClassVar[bool] Loading test/unit/app/managers/test_HistoryManager.py +15 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ from unittest import mock import pytest import sqlalchemy from sqlalchemy import true from sqlalchemy import ( false, true, ) from galaxy import ( exceptions, Loading Loading @@ -956,10 +959,12 @@ class TestHistoryFilters(BaseTestCase): history2 = self.history_manager.create(name="history2", user=user2) history3 = self.history_manager.create(name="history3", user=user2) history4 = self.history_manager.create(name="history4", user=user2) history5 = self.history_manager.create(name="history5", user=user2) self.history_manager.delete(history1) self.history_manager.delete(history2) self.history_manager.delete(history3) self.history_manager.archive_history(history3, None) self.history_manager.archive_history(history4, None) test_annotation = "testing" history2.add_item_annotation(self.trans.sa_session, user2, history2, test_annotation) Loading @@ -969,12 +974,17 @@ class TestHistoryFilters(BaseTestCase): history3.add_item_annotation(self.trans.sa_session, user2, history4, test_annotation) self.trans.sa_session.flush() all_histories = [history1, history2, history3, history4] deleted = [history1, history2, history3] all_histories = [history1, history2, history3, history4, history5] deleted = [history1, history2] archived = [history3, history4] assert self.history_manager.count() == len(all_histories), "having no filters should count all histories" filters = [model.History.deleted == true()] assert self.history_manager.count(filters=filters) == len(deleted), "counting with orm filters should work" assert self.history_manager.count(filters=filters) == len(deleted) filters = [model.History.archived == true()] assert self.history_manager.count(filters=filters) == len(archived) filters = [model.History.deleted == false(), model.History.archived == false()] assert self.history_manager.count(filters=filters) == len(all_histories) - len(deleted) - len(archived) raw_annotation_fn_filter = ("annotation", "has", test_annotation) # functional filtering is not supported Loading Loading
lib/galaxy_test/api/test_histories.py +30 −0 Original line number Diff line number Diff line Loading @@ -407,6 +407,36 @@ class TestHistoriesApi(ApiTestCase, BaseHistories): response = self.dataset_populator.tag_dataset(history_id, hda["id"], ["DatasetTag"], raise_on_error=False) assert response["err_msg"] == "History is immutable" def test_histories_count(self): # Create a new user so we can test the count without other existing histories with self._different_user("user_for_count@test.com"): first_history_id = self._create_history("TestHistoryForCount 1")["id"] self._assert_expected_histories_count(expected_count=1) second_history_id = self._create_history("TestHistoryForCount 2")["id"] self._assert_expected_histories_count(expected_count=2) third_history_id = self._create_history("TestHistoryForCount 3")["id"] self._assert_expected_histories_count(expected_count=3) # Delete the second history self.dataset_populator.delete_history(second_history_id) self._assert_expected_histories_count(expected_count=2) # Archive the first history self.dataset_populator.archive_history(first_history_id) self._assert_expected_histories_count(expected_count=1) # Only the third history should be active active_histories = self._get("histories").json() assert len(active_histories) == 1 assert active_histories[0]["id"] == third_history_id def _assert_expected_histories_count(self, expected_count): response = self._get("histories/count") self._assert_status_code_is(response, 200) assert response.json() == expected_count class ImportExportTests(BaseHistories): task_based: ClassVar[bool] Loading
test/unit/app/managers/test_HistoryManager.py +15 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ from unittest import mock import pytest import sqlalchemy from sqlalchemy import true from sqlalchemy import ( false, true, ) from galaxy import ( exceptions, Loading Loading @@ -956,10 +959,12 @@ class TestHistoryFilters(BaseTestCase): history2 = self.history_manager.create(name="history2", user=user2) history3 = self.history_manager.create(name="history3", user=user2) history4 = self.history_manager.create(name="history4", user=user2) history5 = self.history_manager.create(name="history5", user=user2) self.history_manager.delete(history1) self.history_manager.delete(history2) self.history_manager.delete(history3) self.history_manager.archive_history(history3, None) self.history_manager.archive_history(history4, None) test_annotation = "testing" history2.add_item_annotation(self.trans.sa_session, user2, history2, test_annotation) Loading @@ -969,12 +974,17 @@ class TestHistoryFilters(BaseTestCase): history3.add_item_annotation(self.trans.sa_session, user2, history4, test_annotation) self.trans.sa_session.flush() all_histories = [history1, history2, history3, history4] deleted = [history1, history2, history3] all_histories = [history1, history2, history3, history4, history5] deleted = [history1, history2] archived = [history3, history4] assert self.history_manager.count() == len(all_histories), "having no filters should count all histories" filters = [model.History.deleted == true()] assert self.history_manager.count(filters=filters) == len(deleted), "counting with orm filters should work" assert self.history_manager.count(filters=filters) == len(deleted) filters = [model.History.archived == true()] assert self.history_manager.count(filters=filters) == len(archived) filters = [model.History.deleted == false(), model.History.archived == false()] assert self.history_manager.count(filters=filters) == len(all_histories) - len(deleted) - len(archived) raw_annotation_fn_filter = ("annotation", "has", test_annotation) # functional filtering is not supported Loading