diff --git a/lib/galaxy/managers/citations.py b/lib/galaxy/managers/citations.py index 09a4e137cbee..958617289ebb 100644 --- a/lib/galaxy/managers/citations.py +++ b/lib/galaxy/managers/citations.py @@ -55,6 +55,7 @@ def _raw_get_bibtex(self, doi): # content encoding from the Content-Type header (res.encoding), and if # that fails, falls back to guessing from the content itself (res.apparent_encoding). # The guessed encoding is sometimes wrong, better to default to utf-8. + res.raise_for_status() if res.encoding is None: res.encoding = "utf-8" return res.text diff --git a/lib/galaxy_test/driver/uses_shed.py b/lib/galaxy_test/driver/uses_shed.py index e592de25aefd..f563d516d5a6 100644 --- a/lib/galaxy_test/driver/uses_shed.py +++ b/lib/galaxy_test/driver/uses_shed.py @@ -4,9 +4,12 @@ import string import tempfile from typing import ClassVar +from unittest import SkipTest from galaxy.app import UniverseApplication from galaxy.model.base import transaction +from galaxy.util.tool_shed.tool_shed_registry import DEFAULT_TOOL_SHED_URL +from galaxy.util.unittest_utils import is_site_up from galaxy_test.base.populators import DEFAULT_TIMEOUT from galaxy_test.base.uses_shed_api import UsesShedApi from galaxy_test.driver.driver_util import ( @@ -47,6 +50,8 @@ def _app(self) -> UniverseApplication: ... @classmethod def configure_shed(cls, config): + if not is_site_up(DEFAULT_TOOL_SHED_URL): + raise SkipTest(f"Test depends on [{DEFAULT_TOOL_SHED_URL}] being up and it appears to be down.") cls.shed_tools_dir = tempfile.mkdtemp() cls.shed_tool_data_dir = tempfile.mkdtemp() cls._test_driver.temp_directories.extend([cls.shed_tool_data_dir, cls.shed_tools_dir]) diff --git a/test/unit/app/managers/test_CitationsManager_db.py b/test/unit/app/managers/test_CitationsManager_db.py index 8c7b8f8eb29c..d159015949a9 100644 --- a/test/unit/app/managers/test_CitationsManager_db.py +++ b/test/unit/app/managers/test_CitationsManager_db.py @@ -1,3 +1,6 @@ +from unittest import SkipTest + +import requests from beaker.cache import CacheManager from beaker.util import parse_cache_config_options @@ -29,8 +32,11 @@ def test_DoiCache(url_factory): # noqa: F811 with create_and_drop_database(db_url): doi_cache = MockDoiCache(galaxy.config.GalaxyAppConfiguration(override_tempdir=False), db_url) assert is_cache_empty(db_url, "doi") - assert "Jörg" in doi_cache.get_bibtex("10.1093/bioinformatics/bts252") - assert "Özkurt" in doi_cache.get_bibtex("10.1101/2021.12.24.474111") + try: + assert "Jörg" in doi_cache.get_bibtex("10.1093/bioinformatics/bts252") + assert "Özkurt" in doi_cache.get_bibtex("10.1101/2021.12.24.474111") + except requests.exceptions.RequestException as e: + raise SkipTest(f"dx.doi failed to respond: {e}") assert not is_cache_empty(db_url, "doi") doi_cache._cache.clear() assert is_cache_empty(db_url, "doi") diff --git a/test/unit/app/test_galaxy_install.py b/test/unit/app/test_galaxy_install.py index 1695e8faebc2..a44fc823ad5e 100644 --- a/test/unit/app/test_galaxy_install.py +++ b/test/unit/app/test_galaxy_install.py @@ -17,8 +17,10 @@ from galaxy.tool_shed.unittest_utils import StandaloneInstallationTarget from galaxy.tool_shed.util.repository_util import check_for_updates from galaxy.util.tool_shed.tool_shed_registry import DEFAULT_TOOL_SHED_URL +from galaxy.util.unittest_utils import skip_if_site_down +@skip_if_site_down(DEFAULT_TOOL_SHED_URL) def test_against_production_shed(tmp_path: Path): repo_owner = "iuc" repo_name = "featurecounts"