From 88d76cc1d89e1ffe462069163d20c4d4a52aafc6 Mon Sep 17 00:00:00 2001 From: Germano Guerrini Date: Mon, 22 Aug 2022 17:56:48 +0200 Subject: [PATCH] Changed tests payloads to match current availability --- hda/api.py | 5 +++++ tests/test_hda.py | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hda/api.py b/hda/api.py index e5dce9c..e613031 100644 --- a/hda/api.py +++ b/hda/api.py @@ -397,6 +397,11 @@ def wrapped(*args, **kwargs): if r is not None: if not retriable(r.status_code, r.reason): return r + + if r.status_code == requests.codes.forbidden: + # Try to renew the token next time + self._token_creation_time = None + self.warning( "Recovering from HTTP error [%s %s], attemps %s of %s", r.status_code, diff --git a/tests/test_hda.py b/tests/test_hda.py index f7bdf66..b48dcb3 100644 --- a/tests/test_hda.py +++ b/tests/test_hda.py @@ -46,9 +46,9 @@ def test_hda_1(): ], "dateRangeSelectValues": [ { - "name": "position", - "start": "2021-07-03T00:00:00.000Z", - "end": "2021-07-04T00:00:00.000Z", + "name": "end", + "start": "2022-07-03T00:00:00.000Z", + "end": "2022-07-04T00:00:00.000Z", } ], "stringChoiceValues": [ @@ -58,7 +58,7 @@ def test_hda_1(): } matches = c.search(r) print(matches) - assert len(matches.results) == 2, matches + assert len(matches.results) == 1, matches # Too large to download # matches.download() @@ -68,16 +68,17 @@ def test_hda_2(): c = Client(url="https://wekeo-broker.apps.mercator.dpi.wekeo.eu/databroker") r = { - "datasetId": "EO:ECMWF:DAT:ERA5_HOURLY_VARIABLES_ON_PRESSURE_LEVELS", - "stringChoiceValues": [{"name": "format", "value": "grib"}], + "datasetId": "EO:ECMWF:DAT:CAMS_EUROPE_AIR_QUALITY_REANALYSES", "multiStringSelectValues": [ - {"name": "variable", "value": ["temperature"]}, - {"name": "pressure_level", "value": ["500"]}, - {"name": "product_type", "value": ["ensemble_mean"]}, - {"name": "year", "value": ["2014"]}, - {"name": "month", "value": ["11"]}, - {"name": "day", "value": ["10"]}, - {"name": "time", "value": ["12:00"]}, + {"name": "type", "value": ["validated_reanalysis"]}, + {"name": "variable", "value": ["ammonia"]}, + {"name": "model", "value": ["chimere"]}, + {"name": "level", "value": ["0"]}, + {"name": "month", "value": ["01"]}, + {"name": "year", "value": ["2018"]}, + ], + "stringChoiceValues": [ + {"name": "format", "value": "tgz"}, ], }