From c4705c70f2f7b022465518fa44ef521afc48f5c0 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Tue, 10 Sep 2024 14:24:40 +0200 Subject: [PATCH] fix py3.8 breaking changes --- cads_api_client/catalogue.py | 8 ++++++-- cads_api_client/processing.py | 3 ++- tests/integration_test_40_api_client.py | 10 ++-------- tests/integration_test_50_legacy_api_client.py | 2 ++ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cads_api_client/catalogue.py b/cads_api_client/catalogue.py index 08b325a..a9f7579 100644 --- a/cads_api_client/catalogue.py +++ b/cads_api_client/catalogue.py @@ -35,11 +35,15 @@ def temporal_interval(self) -> tuple[str, str]: @property def begin_datetime(self) -> datetime.datetime: - return datetime.datetime.fromisoformat(self.temporal_interval[0]) + return datetime.datetime.fromisoformat( + self.temporal_interval[0].replace("Z", "+00:00") + ) @property def end_datetime(self) -> datetime.datetime: - return datetime.datetime.fromisoformat(self.temporal_interval[1]) + return datetime.datetime.fromisoformat( + self.temporal_interval[1].replace("Z", "+00:00") + ) @property def id(self) -> str: diff --git a/cads_api_client/processing.py b/cads_api_client/processing.py index 4d87db8..123a138 100644 --- a/cads_api_client/processing.py +++ b/cads_api_client/processing.py @@ -457,7 +457,8 @@ def download( parts = urllib.parse.urlparse(url) target = parts.path.strip("/").split("/")[-1] - download_options = {"stream": True} | self.download_options + download_options = {"stream": True} + download_options.update(self.download_options) multiurl.download( url, target=target, diff --git a/tests/integration_test_40_api_client.py b/tests/integration_test_40_api_client.py index a9a6d12..8f22b1e 100644 --- a/tests/integration_test_40_api_client.py +++ b/tests/integration_test_40_api_client.py @@ -1,8 +1,9 @@ +from __future__ import annotations + import contextlib import datetime import os import pathlib -import warnings from typing import Any import pytest @@ -79,13 +80,6 @@ def test_api_client_verify( api_anon_key: str, tmp_path: pathlib.Path, ) -> None: - secure_client = ApiClient( - url=api_root_url, key=api_anon_key, verify=True, maximum_tries=0 - ) - with warnings.catch_warnings(category=InsecureRequestWarning): - warnings.simplefilter("error") - secure_client.retrieve("test-adaptor-dummy", target=str(tmp_path / "test.grib")) - insecure_client = ApiClient( url=api_root_url, key=api_anon_key, verify=False, maximum_tries=0 ) diff --git a/tests/integration_test_50_legacy_api_client.py b/tests/integration_test_50_legacy_api_client.py index a885291..1db3e11 100644 --- a/tests/integration_test_50_legacy_api_client.py +++ b/tests/integration_test_50_legacy_api_client.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import contextlib import pathlib import time