From 17a6c42f45e55eb19219e386717deb0302020c64 Mon Sep 17 00:00:00 2001 From: Piero Date: Thu, 16 Nov 2023 13:15:22 +0100 Subject: [PATCH] files were formatted correctly --- ohsome/clients.py | 12 +++++++++--- ohsome/test/test_client.py | 12 +++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ohsome/clients.py b/ohsome/clients.py index 47e73cb..507d3e7 100644 --- a/ohsome/clients.py +++ b/ohsome/clients.py @@ -5,6 +5,7 @@ import json import os from urllib.parse import urljoin +import datetime as dt import requests from requests.adapters import HTTPAdapter @@ -122,7 +123,11 @@ def start_timestamp(self): """ if self._metadata is None: self._query_metadata() - return self._metadata["extractRegion"]["temporalExtent"]["fromTimestamp"] + return dt.datetime.fromisoformat( + self._metadata["extractRegion"]["temporalExtent"]["fromTimestamp"].strip( + "Z" + ) + ) @property def end_timestamp(self): @@ -132,8 +137,9 @@ def end_timestamp(self): """ if self._metadata is None: self._query_metadata() - return self._metadata["extractRegion"]["temporalExtent"]["toTimestamp"] - # return dt.datetime.fromisoformat(end_timestamp.strip("Z")) + return dt.datetime.fromisoformat( + self._metadata["extractRegion"]["temporalExtent"]["toTimestamp"].strip("Z") + ) @property def api_version(self): diff --git a/ohsome/test/test_client.py b/ohsome/test/test_client.py index 944a080..7b3a7dc 100644 --- a/ohsome/test/test_client.py +++ b/ohsome/test/test_client.py @@ -17,13 +17,11 @@ logger = logging.getLogger(__name__) -def test_start_and_end_timestamp(base_client): - """ - Get start timestamp - :return: - """ - assert base_client.start_timestamp == "2007-10-08T00:00:00Z" - assert isinstance(base_client.end_timestamp, str) +def test_start_time_is_datetime(base_client): + """Test if the start_timestamp is in datetime format.""" + + assert isinstance(base_client.start_timestamp, dt.datetime) + assert isinstance(base_client.end_timestamp, dt.datetime) def test_api_version(base_client):