From 927dd1551a4dc39f4f5f2f9f07f9ce3b9f6edcd3 Mon Sep 17 00:00:00 2001 From: Piero Badowski <93714096+rp280@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:32:07 +0100 Subject: [PATCH] feat(response): assert all timestamps are without time zone because they are always in UTC anyway closes #103 --- CHANGELOG.md | 1 + ohsome/response.py | 16 ++--- .../test_check_time_parameter_datetime.yaml | 2 +- .../test_check_time_parameter_list.yaml | 2 +- .../test_end_timestamp_as_time_input.yaml | 6 +- .../test_format_bboxes_dataframe.yaml | 2 +- .../test_client/test_format_bboxes_list.yaml | 10 ++-- .../test_format_bcircles_dataframe.yaml | 2 +- .../test_format_bcircles_list.yaml | 8 +-- .../test_format_bcircles_pandas.yaml | 2 +- .../test_client/test_format_bpolys.yaml | 2 +- .../test_post_with_endpoint_string.yaml | 4 +- .../test_client/test_user_agent.yaml | 6 +- .../test_exceptions/test_disable_logging.yaml | 4 +- .../test_exception_connection_reset.yaml | 2 +- .../test_exception_invalid_parameters.yaml | 4 +- .../test_exceptions/test_invalid_url.yaml | 2 +- .../test_exceptions/test_log_bpolys.yaml | 4 +- .../test_exceptions/test_log_curl.yaml | 4 +- .../test_exceptions/test_timeout_error.yaml | 4 +- .../test_contributions_centroid.yaml | 2 +- .../test_contributions_latest.yaml | 2 +- .../test_elementsFullHistory_geometry.yaml | 2 +- .../test_response/test_elements_count.yaml | 2 +- .../test_elements_count_groupby_boundary.yaml | 2 +- ...ts_count_groupby_boundary_groupby_tag.yaml | 2 +- .../test_elements_count_groupby_key.yaml | 2 +- .../test_elements_count_groupby_tag.yaml | 10 ++-- .../test_elements_count_groupby_type.yaml | 2 +- .../test_elements_count_ratio.yaml | 2 +- ...elements_count_ratio_groupby_boundary.yaml | 2 +- .../test_response/test_elements_density.yaml | 2 +- .../test_response/test_elements_geometry.yaml | 2 +- .../test_empty_geodataframe.yaml | 2 +- .../test_response/test_multi_index_false.yaml | 10 ++-- .../test_not_implemented_query.yaml | 2 +- .../test_response/test_users_timestamp.yaml | 2 +- ohsome/test/test_client.py | 1 - ohsome/test/test_response.py | 60 +++++++++++++++++++ 39 files changed, 129 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c7a1e..58a301a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - start and end timestamp meta information of the client are now datetime objects - accept shapely Polygon and MultiPolygon for `bpolys` input parameter - if a request fails a bash script containing the respective `curl` command is logged (if possible). This allows for easier debugging and sharing of failed requests. + - timestamps are converted without timezone information. Deviates from Ohsome API [(Issue #318)](https://github.com/GIScience/ohsome-api/issues/318) ### Changed diff --git a/ohsome/response.py b/ohsome/response.py index 94d582c..e7c11ce 100644 --- a/ohsome/response.py +++ b/ohsome/response.py @@ -112,16 +112,16 @@ def _as_geodataframe( if "@validFrom" in features.columns: features["@validFrom"] = pd.to_datetime( - features["@validFrom"], format="%Y-%m-%dT%H:%M:%SZ" + features["@validFrom"].str.replace("Z", ""), format="ISO8601" ) features["@validTo"] = pd.to_datetime( - features["@validTo"], format="%Y-%m-%dT%H:%M:%SZ" + features["@validTo"].str.replace("Z", ""), format="ISO8601" ) if multi_index: features = features.set_index(["@osmId", "@validFrom", "@validTo"]) elif "@snapshotTimestamp" in features.columns: features["@snapshotTimestamp"] = pd.to_datetime( - features["@snapshotTimestamp"], format="%Y-%m-%dT%H:%M:%SZ" + features["@snapshotTimestamp"].str.replace("Z", ""), format="ISO8601" ) if multi_index: features = features.set_index(["@osmId", "@snapshotTimestamp"]) @@ -129,13 +129,13 @@ def _as_geodataframe( "timestamp" in features.columns and "groupByBoundaryId" in features.columns ): features["timestamp"] = pd.to_datetime( - features["timestamp"], format="%Y-%m-%dT%H:%M:%SZ" + features["timestamp"].str.replace("Z", ""), format="ISO8601" ) if multi_index: features = features.set_index(["groupByBoundaryId", "timestamp"]) elif "@timestamp" in features.columns: features["@timestamp"] = pd.to_datetime( - features["@timestamp"], format="%Y-%m-%dT%H:%M:%SZ" + features["@timestamp"].str.replace("Z", ""), format="ISO8601" ) if multi_index: features = features.set_index(["@timestamp"]) @@ -200,12 +200,12 @@ def _format_timestamp(self, result_df: DataFrame) -> None: """ if "timestamp" in result_df.columns: result_df["timestamp"] = pd.to_datetime( - result_df["timestamp"], format="ISO8601" + result_df["timestamp"].str.replace("Z", ""), format="ISO8601" ) else: result_df["fromTimestamp"] = pd.to_datetime( - result_df["fromTimestamp"], format="ISO8601" + result_df["fromTimestamp"].str.replace("Z", ""), format="ISO8601" ) result_df["toTimestamp"] = pd.to_datetime( - result_df["toTimestamp"], format="ISO8601" + result_df["toTimestamp"].str.replace("Z", ""), format="ISO8601" ) diff --git a/ohsome/test/cassettes/test_client/test_check_time_parameter_datetime.yaml b/ohsome/test/cassettes/test_client/test_check_time_parameter_datetime.yaml index 86751af..6d54c8d 100644 --- a/ohsome/test/cassettes/test_client/test_check_time_parameter_datetime.yaml +++ b/ohsome/test/cassettes/test_client/test_check_time_parameter_datetime.yaml @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:04 GMT + - Wed, 29 Nov 2023 13:54:48 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_check_time_parameter_list.yaml b/ohsome/test/cassettes/test_client/test_check_time_parameter_list.yaml index bfb2f4c..8525244 100644 --- a/ohsome/test/cassettes/test_client/test_check_time_parameter_list.yaml +++ b/ohsome/test/cassettes/test_client/test_check_time_parameter_list.yaml @@ -44,7 +44,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:04 GMT + - Wed, 29 Nov 2023 13:54:48 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_end_timestamp_as_time_input.yaml b/ohsome/test/cassettes/test_client/test_end_timestamp_as_time_input.yaml index ef39cb8..c84f37e 100644 --- a/ohsome/test/cassettes/test_client/test_end_timestamp_as_time_input.yaml +++ b/ohsome/test/cassettes/test_client/test_end_timestamp_as_time_input.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: bcircles=0%3A8.678770065307615%2C49.414435400453954%2C100%7C1%3A8.697137832641602%2C49.41007968889129%2C150&time=2023-11-11T22%3A00%3A00&filter=amenity%3Drestaurant+and+type%3Away + body: bcircles=0%3A8.678770065307615%2C49.414435400453954%2C100%7C1%3A8.697137832641602%2C49.41007968889129%2C150&time=2023-11-25T13%3A00%3A00&filter=amenity%3Drestaurant+and+type%3Away headers: Accept: - '*/*' @@ -20,7 +20,7 @@ interactions: body: string: "{\n \"attribution\" : {\n \"url\" : \"https://ohsome.org/copyrights\",\n \ \"text\" : \"\xA9 OpenStreetMap contributors\"\n },\n \"apiVersion\" - : \"1.10.1\",\n \"result\" : [ {\n \"timestamp\" : \"2023-11-11T22:00:00Z\",\n + : \"1.10.1\",\n \"result\" : [ {\n \"timestamp\" : \"2023-11-25T13:00:00Z\",\n \ \"value\" : 0.0\n } ]\n}" headers: Access-Control-Allow-Credentials: @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:06 GMT + - Wed, 29 Nov 2023 13:54:48 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bboxes_dataframe.yaml b/ohsome/test/cassettes/test_client/test_format_bboxes_dataframe.yaml index 4702274..538ad3f 100644 --- a/ohsome/test/cassettes/test_client/test_format_bboxes_dataframe.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bboxes_dataframe.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:13 GMT + - Wed, 29 Nov 2023 13:54:53 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bboxes_list.yaml b/ohsome/test/cassettes/test_client/test_format_bboxes_list.yaml index cda57d1..ea02d0b 100644 --- a/ohsome/test/cassettes/test_client/test_format_bboxes_list.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bboxes_list.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:13 GMT + - Wed, 29 Nov 2023 13:54:53 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -99,7 +99,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:14 GMT + - Wed, 29 Nov 2023 13:54:53 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -156,7 +156,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:14 GMT + - Wed, 29 Nov 2023 13:54:55 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -213,7 +213,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:16 GMT + - Wed, 29 Nov 2023 13:54:55 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -270,7 +270,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:16 GMT + - Wed, 29 Nov 2023 13:54:55 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bcircles_dataframe.yaml b/ohsome/test/cassettes/test_client/test_format_bcircles_dataframe.yaml index e44fe91..e6d3721 100644 --- a/ohsome/test/cassettes/test_client/test_format_bcircles_dataframe.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bcircles_dataframe.yaml @@ -45,7 +45,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:06 GMT + - Wed, 29 Nov 2023 13:54:49 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bcircles_list.yaml b/ohsome/test/cassettes/test_client/test_format_bcircles_list.yaml index f48fd95..29e8819 100644 --- a/ohsome/test/cassettes/test_client/test_format_bcircles_list.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bcircles_list.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:08 GMT + - Wed, 29 Nov 2023 13:54:51 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -102,7 +102,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:08 GMT + - Wed, 29 Nov 2023 13:54:51 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -159,7 +159,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:09 GMT + - Wed, 29 Nov 2023 13:54:51 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -216,7 +216,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:09 GMT + - Wed, 29 Nov 2023 13:54:52 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml b/ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml index ba88e8b..80c3b1c 100644 --- a/ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml @@ -51,7 +51,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:11 GMT + - Wed, 29 Nov 2023 13:54:52 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bpolys.yaml b/ohsome/test/cassettes/test_client/test_format_bpolys.yaml index a1a74bb..1d62be3 100644 --- a/ohsome/test/cassettes/test_client/test_format_bpolys.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bpolys.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:11 GMT + - Wed, 29 Nov 2023 13:54:52 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_post_with_endpoint_string.yaml b/ohsome/test/cassettes/test_client/test_post_with_endpoint_string.yaml index ba1c230..ccea8c5 100644 --- a/ohsome/test/cassettes/test_client/test_post_with_endpoint_string.yaml +++ b/ohsome/test/cassettes/test_client/test_post_with_endpoint_string.yaml @@ -50,7 +50,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:17 GMT + - Wed, 29 Nov 2023 13:54:56 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -115,7 +115,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:17 GMT + - Wed, 29 Nov 2023 13:54:56 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_user_agent.yaml b/ohsome/test/cassettes/test_client/test_user_agent.yaml index 639317f..f6d09fd 100644 --- a/ohsome/test/cassettes/test_client/test_user_agent.yaml +++ b/ohsome/test/cassettes/test_client/test_user_agent.yaml @@ -20,8 +20,8 @@ interactions: : {\n \"type\" : \"Polygon\",\n \"coordinates\" : [ [ [ -180.0, -90.0 ], [ 180.0, -90.0 ], [ 180.0, 90.0 ], [ -180.0, 90.0 ], [ -180.0, -90.0 ] ] ]\n },\n \"temporalExtent\" : {\n \"fromTimestamp\" : \"2007-10-08T00:00:00Z\",\n - \ \"toTimestamp\" : \"2023-11-11T22:00Z\"\n },\n \"replicationSequenceNumber\" - : 97863\n }\n}" + \ \"toTimestamp\" : \"2023-11-25T13:00Z\"\n },\n \"replicationSequenceNumber\" + : 98190\n }\n}" headers: Access-Control-Allow-Credentials: - 'true' @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:03 GMT + - Wed, 29 Nov 2023 13:54:44 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_exceptions/test_disable_logging.yaml b/ohsome/test/cassettes/test_exceptions/test_disable_logging.yaml index 2c98cf0..7284a22 100644 --- a/ohsome/test/cassettes/test_exceptions/test_disable_logging.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_disable_logging.yaml @@ -18,7 +18,7 @@ interactions: uri: https://api.ohsome.org/v1/elements/geometry response: body: - string: "{\n \"timestamp\" : \"2023-11-17T15:37:19.579114653\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.479125767\",\n \"status\" : 413,\n \"message\" : \"The given query is too large in respect to the given timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\" : \"https://api.ohsome.org/v1/elements/geometry\"\n}" @@ -44,7 +44,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:19 GMT + - Wed, 29 Nov 2023 13:54:56 GMT Server: - Apache Strict-Transport-Security: diff --git a/ohsome/test/cassettes/test_exceptions/test_exception_connection_reset.yaml b/ohsome/test/cassettes/test_exceptions/test_exception_connection_reset.yaml index 5d557c9..3ce90fe 100644 --- a/ohsome/test/cassettes/test_exceptions/test_exception_connection_reset.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_exception_connection_reset.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:26 GMT + - Wed, 29 Nov 2023 13:55:14 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_exceptions/test_exception_invalid_parameters.yaml b/ohsome/test/cassettes/test_exceptions/test_exception_invalid_parameters.yaml index e993adc..1df0927 100644 --- a/ohsome/test/cassettes/test_exceptions/test_exception_invalid_parameters.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_exception_invalid_parameters.yaml @@ -18,7 +18,7 @@ interactions: uri: https://api.ohsome.org/v1/elements/count/groupBy/tag response: body: - string: "{\n \"timestamp\" : \"2023-11-17T15:37:26.890336955\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-29T13:55:14.60175905\",\n \"status\" : 400,\n \"message\" : \"You need to give one groupByKey parameter, if you want to use groupBy/tag.\",\n \"requestUrl\" : \"https://api.ohsome.org/v1/elements/count/groupBy/tag\"\n}" headers: @@ -41,7 +41,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:26 GMT + - Wed, 29 Nov 2023 13:55:14 GMT Server: - Apache Strict-Transport-Security: diff --git a/ohsome/test/cassettes/test_exceptions/test_invalid_url.yaml b/ohsome/test/cassettes/test_exceptions/test_invalid_url.yaml index 7881737..6b5fede 100644 --- a/ohsome/test/cassettes/test_exceptions/test_invalid_url.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_invalid_url.yaml @@ -38,7 +38,7 @@ interactions: Content-Type: - text/html Date: - - Fri, 17 Nov 2023 15:37:19 GMT + - Wed, 29 Nov 2023 13:54:57 GMT ETag: - '"25c-5c7180820e5fc"' Keep-Alive: diff --git a/ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml b/ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml index 36cbd89..ec243e6 100644 --- a/ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml @@ -18,7 +18,7 @@ interactions: uri: https://api.ohsome.org/v1/elements/count response: body: - string: "{\n \"timestamp\" : \"2023-11-17T15:37:20.131942698\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.656277775\",\n \"status\" : 413,\n \"message\" : \"The given query is too large in respect to the given timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\" : \"https://api.ohsome.org/v1/elements/count\"\n}" @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:20 GMT + - Wed, 29 Nov 2023 13:54:57 GMT Server: - Apache Strict-Transport-Security: diff --git a/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml b/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml index 270b745..1b1de46 100644 --- a/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml @@ -18,7 +18,7 @@ interactions: uri: https://api.ohsome.org/v1/elements/count response: body: - string: "{\n \"timestamp\" : \"2023-11-17T12:28:28.06766606\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.759114624\",\n \"status\" : 413,\n \"message\" : \"The given query is too large in respect to the given timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\" : \"https://api.ohsome.org/v1/elements/count\"\n}" @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 12:28:27 GMT + - Wed, 29 Nov 2023 13:54:57 GMT Server: - Apache Strict-Transport-Security: diff --git a/ohsome/test/cassettes/test_exceptions/test_timeout_error.yaml b/ohsome/test/cassettes/test_exceptions/test_timeout_error.yaml index 163c2f9..f36d240 100644 --- a/ohsome/test/cassettes/test_exceptions/test_timeout_error.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_timeout_error.yaml @@ -18,7 +18,7 @@ interactions: uri: https://api.ohsome.org/v1/elements/geometry response: body: - string: "{\n \"timestamp\" : \"2023-11-17T15:37:19.028799445\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.300350483\",\n \"status\" : 413,\n \"message\" : \"The given query is too large in respect to the given timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\" : \"https://api.ohsome.org/v1/elements/geometry\"\n}" @@ -44,7 +44,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:19 GMT + - Wed, 29 Nov 2023 13:54:56 GMT Server: - Apache Strict-Transport-Security: diff --git a/ohsome/test/cassettes/test_response/test_contributions_centroid.yaml b/ohsome/test/cassettes/test_response/test_contributions_centroid.yaml index 851930f..1124c3f 100644 --- a/ohsome/test/cassettes/test_response/test_contributions_centroid.yaml +++ b/ohsome/test/cassettes/test_response/test_contributions_centroid.yaml @@ -46,7 +46,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:41 GMT + - Wed, 29 Nov 2023 13:55:21 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_contributions_latest.yaml b/ohsome/test/cassettes/test_response/test_contributions_latest.yaml index fed5680..081d514 100644 --- a/ohsome/test/cassettes/test_response/test_contributions_latest.yaml +++ b/ohsome/test/cassettes/test_response/test_contributions_latest.yaml @@ -50,7 +50,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:41 GMT + - Wed, 29 Nov 2023 13:55:23 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elementsFullHistory_geometry.yaml b/ohsome/test/cassettes/test_response/test_elementsFullHistory_geometry.yaml index 9794e29..a5e5687 100644 --- a/ohsome/test/cassettes/test_response/test_elementsFullHistory_geometry.yaml +++ b/ohsome/test/cassettes/test_response/test_elementsFullHistory_geometry.yaml @@ -50,7 +50,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:39 GMT + - Wed, 29 Nov 2023 13:55:21 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count.yaml b/ohsome/test/cassettes/test_response/test_elements_count.yaml index f26a8e6..e3dfede 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:28 GMT + - Wed, 29 Nov 2023 13:55:14 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary.yaml b/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary.yaml index cf9a080..d695c6b 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary.yaml @@ -45,7 +45,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:35 GMT + - Wed, 29 Nov 2023 13:55:18 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary_groupby_tag.yaml b/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary_groupby_tag.yaml index de57016..23a8f53 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary_groupby_tag.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_groupby_boundary_groupby_tag.yaml @@ -45,7 +45,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:35 GMT + - Wed, 29 Nov 2023 13:55:18 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_groupby_key.yaml b/ohsome/test/cassettes/test_response/test_elements_count_groupby_key.yaml index 463059d..b62f712 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_groupby_key.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_groupby_key.yaml @@ -50,7 +50,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:30 GMT + - Wed, 29 Nov 2023 13:55:16 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_groupby_tag.yaml b/ohsome/test/cassettes/test_response/test_elements_count_groupby_tag.yaml index 2bb7b0e..0b5ca59 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_groupby_tag.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_groupby_tag.yaml @@ -74,12 +74,12 @@ interactions: : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=doctors\",\n \"result\" : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : 3.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" - : 3.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=fountain\",\n \"result\" - : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : - 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" - : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=parking_entrance\",\n + : 3.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=parking_entrance\",\n \ \"result\" : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" + : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=fountain\",\n \"result\" + : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : + 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=public_building\",\n \ \"result\" : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" @@ -128,7 +128,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:32 GMT + - Wed, 29 Nov 2023 13:55:17 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_groupby_type.yaml b/ohsome/test/cassettes/test_response/test_elements_count_groupby_type.yaml index 0ee0297..fa5e773 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_groupby_type.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_groupby_type.yaml @@ -50,7 +50,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:34 GMT + - Wed, 29 Nov 2023 13:55:18 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_ratio.yaml b/ohsome/test/cassettes/test_response/test_elements_count_ratio.yaml index fc55c5f..bd90996 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_ratio.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_ratio.yaml @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:36 GMT + - Wed, 29 Nov 2023 13:55:20 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_count_ratio_groupby_boundary.yaml b/ohsome/test/cassettes/test_response/test_elements_count_ratio_groupby_boundary.yaml index 6d5b0fa..49cc9da 100644 --- a/ohsome/test/cassettes/test_response/test_elements_count_ratio_groupby_boundary.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_count_ratio_groupby_boundary.yaml @@ -50,7 +50,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:37 GMT + - Wed, 29 Nov 2023 13:55:20 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_density.yaml b/ohsome/test/cassettes/test_response/test_elements_density.yaml index 33d57ec..f3246f2 100644 --- a/ohsome/test/cassettes/test_response/test_elements_density.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_density.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:28 GMT + - Wed, 29 Nov 2023 13:55:16 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_elements_geometry.yaml b/ohsome/test/cassettes/test_response/test_elements_geometry.yaml index cb50762..57c0c44 100644 --- a/ohsome/test/cassettes/test_response/test_elements_geometry.yaml +++ b/ohsome/test/cassettes/test_response/test_elements_geometry.yaml @@ -79,7 +79,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:37 GMT + - Wed, 29 Nov 2023 13:55:20 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_empty_geodataframe.yaml b/ohsome/test/cassettes/test_response/test_empty_geodataframe.yaml index 6c03783..6677a51 100644 --- a/ohsome/test/cassettes/test_response/test_empty_geodataframe.yaml +++ b/ohsome/test/cassettes/test_response/test_empty_geodataframe.yaml @@ -41,7 +41,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 15:37:42 GMT + - Wed, 29 Nov 2023 13:55:23 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_multi_index_false.yaml b/ohsome/test/cassettes/test_response/test_multi_index_false.yaml index 2bb7b0e..0b5ca59 100644 --- a/ohsome/test/cassettes/test_response/test_multi_index_false.yaml +++ b/ohsome/test/cassettes/test_response/test_multi_index_false.yaml @@ -74,12 +74,12 @@ interactions: : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=doctors\",\n \"result\" : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : 3.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" - : 3.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=fountain\",\n \"result\" - : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : - 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" - : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=parking_entrance\",\n + : 3.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=parking_entrance\",\n \ \"result\" : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" + : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=fountain\",\n \"result\" + : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : + 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" : 1.0\n } ]\n }, {\n \"groupByObject\" : \"amenity=public_building\",\n \ \"result\" : [ {\n \"timestamp\" : \"2019-12-10T00:00:00Z\",\n \"value\" : 1.0\n }, {\n \"timestamp\" : \"2019-12-11T00:00:00Z\",\n \"value\" @@ -128,7 +128,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:32 GMT + - Wed, 29 Nov 2023 13:55:17 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_not_implemented_query.yaml b/ohsome/test/cassettes/test_response/test_not_implemented_query.yaml index 463059d..b62f712 100644 --- a/ohsome/test/cassettes/test_response/test_not_implemented_query.yaml +++ b/ohsome/test/cassettes/test_response/test_not_implemented_query.yaml @@ -50,7 +50,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:30 GMT + - Wed, 29 Nov 2023 13:55:16 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_response/test_users_timestamp.yaml b/ohsome/test/cassettes/test_response/test_users_timestamp.yaml index 7120779..8a2ce30 100644 --- a/ohsome/test/cassettes/test_response/test_users_timestamp.yaml +++ b/ohsome/test/cassettes/test_response/test_users_timestamp.yaml @@ -43,7 +43,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 15:37:39 GMT + - Wed, 29 Nov 2023 13:55:21 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/test_client.py b/ohsome/test/test_client.py index b5d4462..2235d60 100644 --- a/ohsome/test/test_client.py +++ b/ohsome/test/test_client.py @@ -19,7 +19,6 @@ def test_start_end_time_is_datetime(base_client): """Test if the start_ end end_timestamp is in datetime format without timezone.""" - assert isinstance(base_client.start_timestamp, dt.datetime) assert isinstance(base_client.end_timestamp, dt.datetime) assert base_client.start_timestamp.tzinfo is None diff --git a/ohsome/test/test_response.py b/ohsome/test/test_response.py index f5d187f..cb0a15a 100644 --- a/ohsome/test/test_response.py +++ b/ohsome/test/test_response.py @@ -6,6 +6,7 @@ import geopandas as gpd import pandas as pd import pytest +import datetime as dt @pytest.mark.vcr @@ -383,3 +384,62 @@ def test_empty_geodataframe(base_client): assert isinstance(result, gpd.GeoDataFrame) assert result.empty + + +def test_all_columns_with_timestamps_to_be_without_timezone(base_client): + """Test whether all the columns with timestamp like 'timestamp', '@timestamp','@validFrom', '@validTo', + 'fromTimestamp', 'toTimestamp' and '@snapshotTimestamp' are without timezone + """ + bbox = "8.67,49.39,8.71,49.42" + time = "2008-01-01/2023-01-01/P1Y" + time2iso = "2020-02-01,2020-06-29" + fltr = "amenity=cafe and type:node" + client = base_client + + fromTimestamp = ( + client.contributions.count.density.post(time=time, bboxes=bbox, filter=fltr) + .as_dataframe() + .index.levels[0][0] + ) + toTimestamp = ( + client.contributions.count.density.post(time=time, bboxes=bbox, filter=fltr) + .as_dataframe() + .index.levels[0][1] + ) + at_validFrom = ( + client.elementsFullHistory.geometry.post( + time=time2iso, bboxes=bbox, filter=fltr + ) + .as_dataframe() + .index.levels[1][0] + ) + at_validTo = ( + client.elementsFullHistory.geometry.post( + time=time2iso, bboxes=bbox, filter=fltr + ) + .as_dataframe() + .index.levels[2][0] + ) + at_timestamp = ( + client.contributions.geometry.post(time=time2iso, bboxes=bbox, filter=fltr) + .as_dataframe() + .index[0] + ) + timestamp = ( + client.elements.count.groupByBoundary.post(bboxes=bbox, time=time, filter=fltr) + .as_dataframe() + .index.levels[1][0] + ) + at_snapshotTimestamp = ( + client.elements.geometry.post(bboxes=bbox, time=time, filter=fltr) + .as_dataframe() + .index.levels[1][0] + ) + + assert fromTimestamp.tz is None + assert toTimestamp.tz is None + assert at_validFrom.tz is None + assert at_validTo.tz is None + assert at_timestamp.tz is None + assert timestamp.tz is None + assert at_snapshotTimestamp.tz is None