From 3671279526ab96bd51c39bc2321362682c0b99d6 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:26:58 +0100 Subject: [PATCH] Replace testable_url_for with mock_url_builder --- test/unit/app/managers/test_DatasetManager.py | 8 ++------ test/unit/app/managers/test_HDAManager.py | 9 ++------- test/unit/app/managers/test_HDCAManager.py | 9 ++------- test/unit/app/managers/test_HistoryManager.py | 11 +++-------- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/test/unit/app/managers/test_DatasetManager.py b/test/unit/app/managers/test_DatasetManager.py index 882e4a97f71c..8847b019f2a4 100644 --- a/test/unit/app/managers/test_DatasetManager.py +++ b/test/unit/app/managers/test_DatasetManager.py @@ -9,6 +9,7 @@ exceptions, model, ) +from galaxy.app_unittest_utils.galaxy_mock import mock_url_builder from galaxy.managers.base import SkipAttribute from galaxy.managers.datasets import ( DatasetManager, @@ -188,12 +189,7 @@ def test_create_private_dataset(self): assert not self.dataset_manager.permissions.access.is_permitted(dataset, None) -# web.url_for doesn't work well in the framework -def testable_url_for(*a, **k): - return f"(fake url): {a}, {k}" - - -@mock.patch("galaxy.managers.datasets.DatasetSerializer.url_for", testable_url_for) +@mock.patch("galaxy.managers.datasets.DatasetSerializer.url_for", mock_url_builder) class TestDatasetSerializer(BaseTestCase): def set_up_managers(self): super().set_up_managers() diff --git a/test/unit/app/managers/test_HDAManager.py b/test/unit/app/managers/test_HDAManager.py index 5692d83eec9e..6c7300a44271 100644 --- a/test/unit/app/managers/test_HDAManager.py +++ b/test/unit/app/managers/test_HDAManager.py @@ -7,6 +7,7 @@ exceptions, model, ) +from galaxy.app_unittest_utils.galaxy_mock import mock_url_builder from galaxy.managers import hdas from galaxy.managers.datasets import DatasetManager from galaxy.managers.histories import HistoryManager @@ -345,13 +346,7 @@ def test_data_conversion_status(self): # def test_text_data( self ): -# ============================================================================= -# web.url_for doesn't work well in the framework -def testable_url_for(*a, **k): - return f"(fake url): {a}, {k}" - - -@mock.patch("galaxy.managers.hdas.HDASerializer.url_for", testable_url_for) +@mock.patch("galaxy.managers.hdas.HDASerializer.url_for", mock_url_builder) class TestHDASerializer(HDATestCase): def set_up_managers(self): super().set_up_managers() diff --git a/test/unit/app/managers/test_HDCAManager.py b/test/unit/app/managers/test_HDCAManager.py index fe4321726394..313520886e45 100644 --- a/test/unit/app/managers/test_HDCAManager.py +++ b/test/unit/app/managers/test_HDCAManager.py @@ -1,5 +1,6 @@ from unittest import mock +from galaxy.app_unittest_utils.galaxy_mock import mock_url_builder from galaxy.managers import ( collections, hdas, @@ -52,13 +53,7 @@ def _create_list_hdca(self, hdas, history=None, name="test collection", **kwargs return hdca -# ============================================================================= -# web.url_for doesn't work well in the framework -def testable_url_for(*a, **k): - return f"(fake url): {a}, {k}" - - -@mock.patch("galaxy.managers.base.ModelSerializer.url_for", testable_url_for) +@mock.patch("galaxy.managers.base.ModelSerializer.url_for", mock_url_builder) class TestHDCASerializer(HDCATestCase): def set_up_managers(self): super().set_up_managers() diff --git a/test/unit/app/managers/test_HistoryManager.py b/test/unit/app/managers/test_HistoryManager.py index 6809f564af82..e9e011c3bf97 100644 --- a/test/unit/app/managers/test_HistoryManager.py +++ b/test/unit/app/managers/test_HistoryManager.py @@ -13,6 +13,7 @@ exceptions, model, ) +from galaxy.app_unittest_utils.galaxy_mock import mock_url_builder from galaxy.managers import ( base, hdas, @@ -391,14 +392,8 @@ def test_rating(self): assert manager.ratings_count(item) == 2 -# ============================================================================= -# web.url_for doesn't work well in the framework -def testable_url_for(*a, **k): - return f"(fake url): {a}, {k}" - - -@mock.patch("galaxy.managers.histories.HistorySerializer.url_for", testable_url_for) -@mock.patch("galaxy.managers.hdas.HDASerializer.url_for", testable_url_for) +@mock.patch("galaxy.managers.histories.HistorySerializer.url_for", mock_url_builder) +@mock.patch("galaxy.managers.hdas.HDASerializer.url_for", mock_url_builder) class TestHistorySerializer(BaseTestCase): def set_up_managers(self): super().set_up_managers()