Skip to content

Commit

Permalink
Replace testable_url_for with mock_url_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Nov 24, 2023
1 parent b4d7d1f commit 3671279
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
8 changes: 2 additions & 6 deletions test/unit/app/managers/test_DatasetManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 2 additions & 7 deletions test/unit/app/managers/test_HDAManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 2 additions & 7 deletions test/unit/app/managers/test_HDCAManager.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 3 additions & 8 deletions test/unit/app/managers/test_HistoryManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
exceptions,
model,
)
from galaxy.app_unittest_utils.galaxy_mock import mock_url_builder
from galaxy.managers import (
base,
hdas,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 3671279

Please sign in to comment.