diff --git a/tests/test_40_results.py b/tests/test_40_results.py index 18f885e..f41690f 100644 --- a/tests/test_40_results.py +++ b/tests/test_40_results.py @@ -6,24 +6,25 @@ from cads_api_client import Results -RESULTS_URL = "http://localhost:8080/api/retrieve/v1/jobs/bcfc677f-2a4e-4e83-91da-7d1c0340f407/results" - - -def make_results(size: int = 1) -> Results: - results_json = { - "asset": { - "value": { - "type": "application/x-grib", - "href": f"http://httpbin.org/bytes/{size}", - "file:size": size, - } +RESULTS_URL = "http://localhost:8080/api/retrieve/v1/jobs/9bfc1362-2832-48e1-a235-359267420bb2/results" +RESULTS_JSON = { + "asset": { + "value": { + "type": "application/x-grib", + "href": "http://httpbin.org/bytes/1", + "file:size": 1, } } +} + + +@pytest.fixture +def results() -> Results: with responses.RequestsMock() as rsps: rsps.add( responses.GET, RESULTS_URL, - json=results_json, + json=RESULTS_JSON, status=200, content_type="application/json", ) @@ -42,11 +43,6 @@ def make_results(size: int = 1) -> Results: return results -@pytest.fixture -def results() -> Results: - return make_results() - - @pytest.mark.parametrize("target", ("dummy.grib", None)) def test_results_download( monkeypatch: pytest.MonkeyPatch, @@ -77,15 +73,7 @@ def test_results_content_type(results: Results) -> None: def test_results_json(results: Results) -> None: - assert results.json == { - "asset": { - "value": { - "type": "application/x-grib", - "href": "http://httpbin.org/bytes/1", - "file:size": 1, - } - } - } + assert results.json == RESULTS_JSON def test_results_location(results: Results) -> None: