Skip to content

Commit

Permalink
Merge pull request #13 from GermanoGuerrini/refreshed_token
Browse files Browse the repository at this point in the history
Refreshed token
  • Loading branch information
ricardo-correa authored Sep 12, 2022
2 parents 93842c5 + 7e8102e commit f9b66fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions hda/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 14 additions & 13 deletions tests/test_hda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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()

Expand All @@ -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"},
],
}

Expand Down

0 comments on commit f9b66fd

Please sign in to comment.