mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-19 02:21:32 +08:00
Skip doi unit test if request fails
This commit is contained in:
@@ -55,6 +55,7 @@ class DoiCache:
|
||||
# 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
|
||||
|
||||
@@ -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")
|
||||
assert not is_cache_empty(db_url, "doi")
|
||||
doi_cache._cache.clear()
|
||||
assert is_cache_empty(db_url, "doi")
|
||||
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")
|
||||
assert not is_cache_empty(db_url, "doi")
|
||||
doi_cache._cache.clear()
|
||||
assert is_cache_empty(db_url, "doi")
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise SkipTest(f"dx.doi failed to respond: {e}")
|
||||
|
||||
Reference in New Issue
Block a user