Unverified Commit d2271e5e authored by mvdbeek's avatar mvdbeek
Browse files

Replace httpbin service with pytest-httpserver

httpbin isn't doing too well, this should be more robust.
parent 22f35454
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ pytest-asyncio==0.20.3 ; python_version >= "3.7" and python_version < "3.12"
pytest-celery==0.0.0 ; python_version >= "3.7" and python_version < "3.12"
pytest-cov==4.0.0 ; python_version >= "3.7" and python_version < "3.12"
pytest-html==3.2.0 ; python_version >= "3.7" and python_version < "3.12"
pytest-httpserver==1.0.6 ; python_version >= "3.7" and python_version < "3.12"
pytest-json-report==1.5.0 ; python_version >= "3.7" and python_version < "3.12"
pytest-metadata==2.0.4 ; python_version >= "3.7" and python_version < "3.12"
pytest-mock==3.10.0 ; python_version >= "3.7" and python_version < "3.12"
+1 −0
Original line number Diff line number Diff line
pytest
pytest-httpserver
responses
+1 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ pytest-asyncio = "*"
pytest-celery = "*"
pytest-cov = "*"
pytest-html = "*"
pytest-httpserver = "*"
python-irodsclient = "!=1.1.2"  # https://github.com/irods/python-irodsclient/issues/356
pytest-json-report = "*"
pytest-mock = "*"
+3 −4
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ import requests
import responses

from galaxy.util import url_get
from galaxy.util.unittest_utils import skip_if_site_down


@responses.activate
@@ -23,11 +22,11 @@ def test_get_url_forbidden():
    assert "403 Client Error: Forbidden for url: https://toolshed.g2.bx.psu.edu/" in str(excinfo)


@skip_if_site_down("https://httpbin.org")
def test_get_url_retry_after():
def test_get_url_retry_after(httpserver):
    # This test is not ideal since it contacts an external resource
    # and doesn't actually verify multiple attempts have been made.
    # responses doesn't mock the right place to fully simulate this.
    url = "https://httpbin.org/status/429"
    httpserver.expect_request("/429").respond_with_data("try again later", status=429, content_type="text/plain")
    url = httpserver.url_for("/429")
    with pytest.raises(requests.exceptions.RetryError):
        url_get(url, max_retries=2, backoff_factor=0.01)