Skip to content

Commit

Permalink
files were formatted correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
rp280 committed Nov 16, 2023
1 parent bf6c26c commit 17a6c42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 9 additions & 3 deletions ohsome/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import os
from urllib.parse import urljoin
import datetime as dt

import requests
from requests.adapters import HTTPAdapter
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
12 changes: 5 additions & 7 deletions ohsome/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 17a6c42

Please sign in to comment.