From 49023a4ab48d907ddb7589e2ea54a7bc0f05468f Mon Sep 17 00:00:00 2001 From: Moritz Schott Date: Fri, 17 Nov 2023 17:16:52 +0100 Subject: [PATCH 1/6] feat: add curl command to logging closes: #42 Co-authored-by: Christina Ludwig --- CHANGELOG.md | 1 + ohsome/exceptions.py | 11 ++++ .../test_exceptions/test_log_curl.yaml | 57 +++++++++++++++++++ ohsome/test/test_exceptions.py | 34 ++++++++++- poetry.lock | 13 ++++- pyproject.toml | 1 + 6 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 ohsome/test/cassettes/test_exceptions/test_log_curl.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 24f141b..1957777 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - support for python 3.12 - custom [retry](https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.Retry) configuration - start and end timestamp meta information of the client are now datetime objects + - 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. ### Removed diff --git a/ohsome/exceptions.py b/ohsome/exceptions.py index e5725fb..efc38d1 100644 --- a/ohsome/exceptions.py +++ b/ohsome/exceptions.py @@ -7,6 +7,8 @@ import json from pathlib import Path +from curlify2 import Curlify + class OhsomeException(Exception): """Exception to handle ohsome API errors""" @@ -33,8 +35,17 @@ def log(self, log_dir: Path): self.log_bpolys(log_dir, log_file_name) self.log_parameter(log_dir, log_file_name) if self.response is not None: + self.log_curl(log_dir, log_file_name) self.log_response(log_dir, log_file_name) + def log_curl(self, log_dir: Path, log_file_name: str) -> None: + """Log the respective curl command for the request for easy debugging and sharing.""" + log_file = log_dir / f"{log_file_name}_curl.sh" + curl = Curlify(self.response.request) + curl_command = curl.to_curl() + with log_file.open(mode="w") as dst: + dst.write(curl_command) + def log_response(self, log_dir: Path, log_file_name: str): """ Log raw response. This may duplicate much data but is helpful for debugging to know the exact raw answer by the diff --git a/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml b/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml new file mode 100644 index 0000000..270b745 --- /dev/null +++ b/ohsome/test/cassettes/test_exceptions/test_log_curl.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: bboxes=8.67555%2C49.39885%2C8.69637%2C49.41122&timeout=0.001 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '60' + Content-Type: + - application/x-www-form-urlencoded + user-agent: + - ohsome-py/0.2.0 + method: POST + uri: https://api.ohsome.org/v1/elements/count + response: + body: + string: "{\n \"timestamp\" : \"2023-11-17T12:28:28.06766606\",\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}" + headers: + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Headers: + - Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization + Access-Control-Allow-Methods: + - POST, GET + Access-Control-Allow-Origin: + - '*' + Access-Control-Max-Age: + - '3600' + Cache-Control: + - no-cache, no-store, must-revalidate + Connection: + - close + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Fri, 17 Nov 2023 12:28:27 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=63072000; includeSubdomains; + Transfer-Encoding: + - chunked + vary: + - accept-encoding + status: + code: 413 + message: '' +version: 1 diff --git a/ohsome/test/test_exceptions.py b/ohsome/test/test_exceptions.py index 8787051..995f112 100644 --- a/ohsome/test/test_exceptions.py +++ b/ohsome/test/test_exceptions.py @@ -118,7 +118,12 @@ def test_log_bpolys(base_client_without_log, tmpdir): base_client_without_log.elements.count.post( bpolys=bpolys, time=time, filter=fltr, timeout=timeout ) - log_file_patterns = ["ohsome_*_bpolys.geojson", "ohsome_*.json", "ohsome_*raw.txt"] + log_file_patterns = [ + "ohsome_*_bpolys.geojson", + "ohsome_*_curl.sh", + "ohsome_*.json", + "ohsome_*raw.txt", + ] for p in log_file_patterns: log_file = list(Path(base_client_without_log.log_dir).glob(p)) assert len(log_file) == 1, f"Log file {p} not found" @@ -126,6 +131,33 @@ def test_log_bpolys(base_client_without_log, tmpdir): log_file[0].unlink() +@pytest.mark.vcr +def test_log_curl(base_client_without_log, tmpdir): + """ + Test whether log file containing curl command is created when request fails + :return: + """ + + base_client_without_log.log = True + base_client_without_log.log_dir = tmpdir.mkdir("logs").strpath + + bboxes = [8.67555, 49.39885, 8.69637, 49.41122] + timeout = 0.001 + + with pytest.raises(ohsome.OhsomeException): + base_client_without_log.elements.count.post(bboxes=bboxes, timeout=timeout) + + log_file = list(Path(base_client_without_log.log_dir).glob("ohsome_*_curl.sh")) + with open(log_file[0]) as file: + assert file.read() == ( + 'curl -X POST -H "user-agent: ohsome-py/0.2.0" -H "Accept-Encoding: gzip, ' + 'deflate" -H "Accept: */*" -H "Connection: keep-alive" -H "Content-Length: 60" ' + '-H "Content-Type: application/x-www-form-urlencoded" ' + "-d 'bboxes=8.67555%2C49.39885%2C8.69637%2C49.41122&timeout=0.001' " + "https://api.ohsome.org/v1/elements/count" + ) + + def test_metadata_invalid_baseurl(custom_client_with_wrong_url): """ Throw exception if the ohsome API is not available diff --git a/poetry.lock b/poetry.lock index 7362e71..da16bd2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -514,6 +514,17 @@ traitlets = ">=4" [package.extras] test = ["pytest"] +[[package]] +name = "curlify2" +version = "2.0.0" +description = "Library to convert python requests and httpx object to curl command." +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "curlify2-2.0.0-py3-none-any.whl", hash = "sha256:23878b13fa33ed92ae5dff0476e5b881b39fc79a5fcb37e6726f96239a136474"}, + {file = "curlify2-2.0.0.tar.gz", hash = "sha256:6c3a98dc8603b76da990f58754b18ec4e9bfe5b881fc52d33ddf9d9096568809"}, +] + [[package]] name = "debugpy" version = "1.8.0" @@ -3005,4 +3016,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "a88b70fa86e8b500ab8e2ab90a07bbf00091c7dbfb75eaa1410c96ef8574aa71" +content-hash = "1f9dcaf124ff252719359a924e1dc99c248a0839434b194fdaabda7c5662e65b" diff --git a/pyproject.toml b/pyproject.toml index b124e47..d3e96d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ pandas = "^2.1.3" numpy = "^1.20.0" geopandas = "^0.14.1" urllib3 = "^2.1.0" +curlify2 = "^2.0.0" [tool.poetry.group.test.dependencies] pytest = "^7.4.3" From 28a1f354117b2a2eee9cb6d3152aeca6adafdeb4 Mon Sep 17 00:00:00 2001 From: Moritz Schott Date: Fri, 17 Nov 2023 20:29:04 +0100 Subject: [PATCH 2/6] feat: accept shapely polygonal for bpolys input and add typing closes #100 Co-authored-by: Christina Ludwig --- CHANGELOG.md | 1 + ohsome/clients.py | 70 ++++++++++++++----- ohsome/helper.py | 56 ++++++++++++--- .../test_check_time_parameter_datetime.yaml | 2 +- .../test_check_time_parameter_list.yaml | 2 +- .../test_end_timestamp_as_time_input.yaml | 2 +- .../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 +-- ....yaml => test_format_bcircles_pandas.yaml} | 2 +- .../test_client/test_format_bpolys.yaml | 6 +- .../test_post_with_endpoint_string.yaml | 4 +- .../test_client/test_user_agent.yaml | 2 +- .../test_exceptions/test_disable_logging.yaml | 4 +- .../test_exception_connection_reset.yaml | 6 +- .../test_exception_invalid_parameters.yaml | 4 +- .../test_exceptions/test_invalid_url.yaml | 2 +- .../test_exceptions/test_log_bpolys.yaml | 8 +-- .../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 | 2 +- .../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 | 2 +- .../test_not_implemented_query.yaml | 2 +- .../test_response/test_users_timestamp.yaml | 2 +- ohsome/test/data/polygons.geojson | 2 + ohsome/test/test_client.py | 24 +++---- ohsome/test/test_helper.py | 25 +++++++ 40 files changed, 189 insertions(+), 93 deletions(-) rename ohsome/test/cassettes/test_client/{test_format_bcircles_geodataframe.yaml => test_format_bcircles_pandas.yaml} (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1957777..8f218bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - support for python 3.12 - custom [retry](https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.Retry) configuration - 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. ### Removed diff --git a/ohsome/clients.py b/ohsome/clients.py index 375b8bf..7358324 100644 --- a/ohsome/clients.py +++ b/ohsome/clients.py @@ -5,10 +5,13 @@ import datetime as dt import json from pathlib import Path -from typing import Union, Optional +from typing import Union, Optional, List from urllib.parse import urljoin +import geopandas as gpd +import pandas as pd import requests +import shapely from requests import Session from requests.adapters import HTTPAdapter from requests.exceptions import RetryError @@ -234,22 +237,53 @@ def __init__( def post( self, - bboxes=None, - bcircles=None, - bpolys=None, - time=None, - filter=None, - filter2=None, - format=None, - showMetadata=None, - timeout=None, - groupByKey=None, - groupByKeys=None, - groupByValues=None, - properties=None, - clipGeometry=None, - endpoint=None, - ): + bboxes: Optional[ + Union[ + str, + dict, + pd.DataFrame, + List[str], + List[float], + List[List[str]], + List[List[float]], + ] + ] = None, + bcircles: Optional[ + Union[ + str, + List[str], + List[float], + List[List[str]], + List[List[float]], + dict, + gpd.GeoDataFrame, + pd.DataFrame, + ] + ] = None, + bpolys: Optional[ + Union[ + gpd.GeoDataFrame, + gpd.GeoSeries, + shapely.Polygon, + shapely.MultiPolygon, + str, + ] + ] = None, + time: Optional[ + Union[str, dt.datetime, dt.date, list, pd.DatetimeIndex, pd.Series] + ] = None, + filter: Optional[str] = None, + filter2: Optional[str] = None, + format: Optional[str] = None, + showMetadata: Optional[bool] = None, + timeout: Optional[int] = None, + groupByKey: Optional[str] = None, + groupByKeys: Optional[Union[str, List[str]]] = None, + groupByValues: Optional[Union[str, List[str]]] = None, + properties: Optional[Union[str, List[str]]] = None, + clipGeometry: Optional[bool] = None, + endpoint: Optional[str] = None, + ) -> OhsomeResponse: """ Sends request to ohsome API @@ -266,7 +300,7 @@ def post( - pandas.DataFrame with columns 'lon', 'lat' and 'radius' - geopandas.GeoDataFrame with geometry column with Point geometries only and a column 'radius'. - :param bpolys: Polygons given as geopandas.GeoDataFrame, GeoJSON FeatureCollection or str + :param bpolys: Polygons given as geopandas.GeoDataFrame, geopandas.GeoSeries, shapely.Polygon, shapely.MultiPolygon, GeoJSON FeatureCollection or str e.g. "8.65821,49.41129,8.65821,49.41825,8.70053,8.65821|8.67817,49.42147,8.67817,49.4342,8.67817" :param time: One or more ISO-8601 conform timestring(s) given as str, list, pandas.Series, pandas.DateTimeIndex, diff --git a/ohsome/helper.py b/ohsome/helper.py index ae4e2c0..57dc257 100644 --- a/ohsome/helper.py +++ b/ohsome/helper.py @@ -4,12 +4,14 @@ """Ohsome utility functions""" import datetime +import json import re -from typing import Tuple +from typing import Tuple, Union, List import geopandas as gpd import numpy as np import pandas as pd +import shapely from ohsome import OhsomeException @@ -73,7 +75,18 @@ def format_boundary(params: dict) -> dict: return params -def format_bcircles(bcircles): +def format_bcircles( + bcircles: Union[ + str, + List[str], + List[float], + List[List[str]], + List[List[float]], + dict, + gpd.GeoDataFrame, + pd.DataFrame, + ] +) -> str: """ Formats bcircles parameter to comply with ohsome API :param @@ -103,9 +116,12 @@ def format_bcircles(bcircles): ] ) elif isinstance(bcircles, gpd.GeoDataFrame): - if bcircles.geometry.geom_type.unique() != ["Point"]: + if (bcircles.geometry.geom_type.unique() != ["Point"]) or ( + "radius" not in bcircles.columns + ): raise OhsomeException( - message="The geometry of the 'bcircles' GeoDataFrame may only include 'Point' geometry types." + message="The geometry of the 'bcircles' GeoDataFrame may only include 'Point' geometry types and " + "requires a 'radius' column." ) formatted = bcircles.apply( lambda r: f"{int(r.name)}:{r.geometry.x},{r.geometry.y},{r['radius']}", @@ -127,7 +143,17 @@ def format_bcircles(bcircles): raise OhsomeException(message="'bcircles' parameter has invalid format.") -def format_bboxes(bboxes): +def format_bboxes( + bboxes: Union[ + str, + dict, + pd.DataFrame, + List[str], + List[float], + List[List[str]], + List[List[float]], + ] +) -> str: """ Formats bboxes parameter to comply with ohsome API :param @@ -177,17 +203,31 @@ def format_bboxes(bboxes): ) -def format_bpolys(bpolys): +def format_bpolys( + bpolys: Union[gpd.GeoDataFrame, shapely.Polygon, shapely.MultiPolygon, str] +) -> str: """ Formats bpolys parameter to comply with ohsome API :param bpolys: Polygons given as geopandas.GeoDataFrame or string formatted as GeoJSON FeatureCollection. :return: """ - if isinstance(bpolys, gpd.GeoDataFrame): + if isinstance(bpolys, gpd.GeoDataFrame) or isinstance(bpolys, gpd.GeoSeries): return bpolys.to_json(na="drop") + elif isinstance(bpolys, shapely.Polygon) or isinstance( + bpolys, shapely.MultiPolygon + ): + return format_bpolys(gpd.GeoDataFrame(geometry=[bpolys])) + elif isinstance(bpolys, str): + try: + return format_bpolys(gpd.GeoDataFrame.from_features(json.loads(bpolys))) + except Exception as e: + raise OhsomeException(message="Invalid geojson.") from e else: - return bpolys + raise OhsomeException( + message="bpolys must be a geojson string, a shapely polygonal object or a geopandas " + "object" + ) def format_list_parameters(parameters: dict) -> dict: 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 4666000..86751af 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 11:28:23 GMT + - Fri, 17 Nov 2023 15:37:04 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 af18d88..bfb2f4c 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 11:28:23 GMT + - Fri, 17 Nov 2023 15:37:04 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 099f942..ef39cb8 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 @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:26 GMT + - Fri, 17 Nov 2023 15:37:06 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 ef04d0f..4702274 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 11:28:32 GMT + - Fri, 17 Nov 2023 15:37:13 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 d4be934..cda57d1 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 11:28:32 GMT + - Fri, 17 Nov 2023 15:37:13 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -99,7 +99,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:34 GMT + - Fri, 17 Nov 2023 15:37:14 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -156,7 +156,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:34 GMT + - Fri, 17 Nov 2023 15:37:14 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -213,7 +213,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:36 GMT + - Fri, 17 Nov 2023 15:37:16 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -270,7 +270,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:36 GMT + - Fri, 17 Nov 2023 15:37:16 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 e841da2..e44fe91 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 11:28:26 GMT + - Fri, 17 Nov 2023 15:37:06 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 75564e6..f48fd95 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 11:28:27 GMT + - Fri, 17 Nov 2023 15:37:08 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -102,7 +102,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:27 GMT + - Fri, 17 Nov 2023 15:37:08 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -159,7 +159,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:29 GMT + - Fri, 17 Nov 2023 15:37:09 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -216,7 +216,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:29 GMT + - Fri, 17 Nov 2023 15:37:09 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/cassettes/test_client/test_format_bcircles_geodataframe.yaml b/ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml similarity index 98% rename from ohsome/test/cassettes/test_client/test_format_bcircles_geodataframe.yaml rename to ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml index 5d21cf5..ba88e8b 100644 --- a/ohsome/test/cassettes/test_client/test_format_bcircles_geodataframe.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 11:28:31 GMT + - Fri, 17 Nov 2023 15:37:11 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 50027e8..a1a74bb 100644 --- a/ohsome/test/cassettes/test_client/test_format_bpolys.yaml +++ b/ohsome/test/cassettes/test_client/test_format_bpolys.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22id%22%3A+%220%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.695077896118164%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.408711468953854%5D%5D%5D%7D%7D%2C+%7B%22id%22%3A+%221%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.677010536193848%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.41370947536709%5D%5D%5D%7D%7D%5D%7D&time=2018-01-01&filter=amenity%3Drestaurant+and+type%3Anode + body: bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22id%22%3A+%220%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%22id%22%3A+%220%22%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.695077896118164%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.408711468953854%5D%5D%5D%7D%7D%2C+%7B%22id%22%3A+%221%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%22id%22%3A+%221%22%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.677010536193848%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.41370947536709%5D%5D%5D%7D%7D%5D%7D&time=2018-01-01&filter=amenity%3Drestaurant+and+type%3Anode headers: Accept: - '*/*' @@ -9,7 +9,7 @@ interactions: Connection: - keep-alive Content-Length: - - '975' + - '1013' Content-Type: - application/x-www-form-urlencoded user-agent: @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:31 GMT + - Fri, 17 Nov 2023 15:37:11 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 35e399e..ba1c230 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 11:28:37 GMT + - Fri, 17 Nov 2023 15:37:17 GMT Keep-Alive: - timeout=5, max=100 Server: @@ -115,7 +115,7 @@ interactions: Content-disposition: - attachment;filename=ohsome.geojson Date: - - Fri, 17 Nov 2023 11:28:37 GMT + - Fri, 17 Nov 2023 15:37:17 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 6b0bef1..639317f 100644 --- a/ohsome/test/cassettes/test_client/test_user_agent.yaml +++ b/ohsome/test/cassettes/test_client/test_user_agent.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:22 GMT + - Fri, 17 Nov 2023 15:37:03 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 21d9dc8..2c98cf0 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-17T11:28:39.812288772\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-17T15:37:19.579114653\",\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 11:28:39 GMT + - Fri, 17 Nov 2023 15:37:19 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 941d34c..5d557c9 100644 --- a/ohsome/test/cassettes/test_exceptions/test_exception_connection_reset.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_exception_connection_reset.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22id%22%3A+%220%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.695077896118164%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.408711468953854%5D%5D%5D%7D%7D%2C+%7B%22id%22%3A+%221%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.677010536193848%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.41370947536709%5D%5D%5D%7D%7D%5D%7D&time=2018-01-01&filter=name%3DKrautturm+and+type%3Away + body: bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22id%22%3A+%220%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%22id%22%3A+%220%22%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.695077896118164%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.408711468953854%5D%5D%5D%7D%7D%2C+%7B%22id%22%3A+%221%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%22id%22%3A+%221%22%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.677010536193848%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.41370947536709%5D%5D%5D%7D%7D%5D%7D&time=2018-01-01&filter=name%3DKrautturm+and+type%3Away headers: Accept: - '*/*' @@ -9,7 +9,7 @@ interactions: Connection: - keep-alive Content-Length: - - '970' + - '1008' Content-Type: - application/x-www-form-urlencoded user-agent: @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:47 GMT + - Fri, 17 Nov 2023 15:37:26 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 627109b..e993adc 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-17T11:28:47.569104003\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-17T15:37:26.890336955\",\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 11:28:47 GMT + - Fri, 17 Nov 2023 15:37:26 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 d54ba88..7881737 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 11:28:39 GMT + - Fri, 17 Nov 2023 15:37:19 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 5201dff..36cbd89 100644 --- a/ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml +++ b/ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22id%22%3A+%220%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.695077896118164%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.408711468953854%5D%5D%5D%7D%7D%2C+%7B%22id%22%3A+%221%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.677010536193848%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.41370947536709%5D%5D%5D%7D%7D%5D%7D&time=2018-01-01&filter=amenity%3Drestaurant+and+type%3Anode&timeout=0.001 + body: bpolys=%7B%22type%22%3A+%22FeatureCollection%22%2C+%22features%22%3A+%5B%7B%22id%22%3A+%220%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%22id%22%3A+%220%22%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.695077896118164%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.408711468953854%5D%2C+%5B8.699712753295898%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.41155955732304%5D%2C+%5B8.695077896118164%2C+49.408711468953854%5D%5D%5D%7D%7D%2C+%7B%22id%22%3A+%221%22%2C+%22type%22%3A+%22Feature%22%2C+%22properties%22%3A+%7B%22id%22%3A+%221%22%7D%2C+%22geometry%22%3A+%7B%22type%22%3A+%22Polygon%22%2C+%22coordinates%22%3A+%5B%5B%5B8.677010536193848%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.41370947536709%5D%2C+%5B8.682074546813965%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.416641030041134%5D%2C+%5B8.677010536193848%2C+49.41370947536709%5D%5D%5D%7D%7D%5D%7D&time=2018-01-01&filter=amenity%3Drestaurant+and+type%3Anode&timeout=0.001 headers: Accept: - '*/*' @@ -9,7 +9,7 @@ interactions: Connection: - keep-alive Content-Length: - - '989' + - '1027' Content-Type: - application/x-www-form-urlencoded user-agent: @@ -18,7 +18,7 @@ interactions: uri: https://api.ohsome.org/v1/elements/count response: body: - string: "{\n \"timestamp\" : \"2023-11-17T11:28:40.637302314\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-17T15:37:20.131942698\",\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 11:28:39 GMT + - Fri, 17 Nov 2023 15:37:20 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 1795c1a..163c2f9 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-17T11:28:39.141569932\",\n \"status\" + string: "{\n \"timestamp\" : \"2023-11-17T15:37:19.028799445\",\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 11:28:38 GMT + - Fri, 17 Nov 2023 15:37:19 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 0a90ac6..851930f 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 11:29:01 GMT + - Fri, 17 Nov 2023 15:37:41 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 ff9027b..fed5680 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 11:29:01 GMT + - Fri, 17 Nov 2023 15:37:41 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 2a676f0..9794e29 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 11:28:59 GMT + - Fri, 17 Nov 2023 15:37:39 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 20b765e..f26a8e6 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 11:28:49 GMT + - Fri, 17 Nov 2023 15:37:28 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 dc1d8b3..cf9a080 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 11:28:54 GMT + - Fri, 17 Nov 2023 15:37:35 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 ed05b48..de57016 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 11:28:56 GMT + - Fri, 17 Nov 2023 15:37:35 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 4bc8fea..463059d 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 11:28:50 GMT + - Fri, 17 Nov 2023 15:37:30 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 bc5017e..2bb7b0e 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 @@ -128,7 +128,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:52 GMT + - Fri, 17 Nov 2023 15:37:32 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 748ba3f..0ee0297 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 11:28:54 GMT + - Fri, 17 Nov 2023 15:37:34 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 1e8c9c8..fc55c5f 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 11:28:56 GMT + - Fri, 17 Nov 2023 15:37:36 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 87837f7..6d5b0fa 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 11:28:57 GMT + - Fri, 17 Nov 2023 15:37:37 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 fc5fb0c..33d57ec 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 11:28:49 GMT + - Fri, 17 Nov 2023 15:37:28 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 b9138aa..cb50762 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 11:28:57 GMT + - Fri, 17 Nov 2023 15:37:37 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 b7cb90b..6c03783 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 11:29:03 GMT + - Fri, 17 Nov 2023 15:37:42 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 bc5017e..2bb7b0e 100644 --- a/ohsome/test/cassettes/test_response/test_multi_index_false.yaml +++ b/ohsome/test/cassettes/test_response/test_multi_index_false.yaml @@ -128,7 +128,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 17 Nov 2023 11:28:52 GMT + - Fri, 17 Nov 2023 15:37:32 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 4bc8fea..463059d 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 11:28:50 GMT + - Fri, 17 Nov 2023 15:37:30 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 78c222a..7120779 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 11:28:59 GMT + - Fri, 17 Nov 2023 15:37:39 GMT Keep-Alive: - timeout=5, max=100 Server: diff --git a/ohsome/test/data/polygons.geojson b/ohsome/test/data/polygons.geojson index 5a25342..f208fc5 100644 --- a/ohsome/test/data/polygons.geojson +++ b/ohsome/test/data/polygons.geojson @@ -4,6 +4,7 @@ { "type": "Feature", "properties": {}, + "id": "0", "geometry": { "type": "Polygon", "coordinates": [ @@ -35,6 +36,7 @@ { "type": "Feature", "properties": {}, + "id": "1", "geometry": { "type": "Polygon", "coordinates": [ diff --git a/ohsome/test/test_client.py b/ohsome/test/test_client.py index 3efb55c..b5d4462 100644 --- a/ohsome/test/test_client.py +++ b/ohsome/test/test_client.py @@ -144,9 +144,9 @@ def test_format_bcircles_list(base_client): @pytest.mark.vcr -def test_format_bcircles_geodataframe(base_client): +def test_format_bcircles_pandas(base_client): """ - Test whether a GeoDataFrame object given as 'bcircles' is formatted correctly. + Test whether a pandas.DataFrame object given as 'bcircles' is formatted correctly. :return: """ bcircles = gpd.read_file(f"{script_path}/data/points.geojson") @@ -175,8 +175,8 @@ def test_format_bcircles_geodataframe_geometry_error(base_client): bcircles=bcircles, time=time, filter=fltr ) assert ( - "The geometry of the 'bcircles' GeoDataFrame may only include 'Point' geometry types." - in e_info.value.message + "The geometry of the 'bcircles' GeoDataFrame may only include 'Point' geometry types and requires a 'radius' " + "column." in e_info.value.message ) del client @@ -251,17 +251,11 @@ def test_format_bboxes_geodataframe(base_client): client = base_client with pytest.raises(ohsome.OhsomeException) as e_info: client.elements.count.post(bboxes=data, time=time, filter=fltr) - if "occurred at index 0" in e_info.value.message: - # Python 3.6 does some weird stuff with the output. So it differs a bit. - assert ( - "Column ('minx', 'occurred at index 0') is missing in the dataframe provided as 'bboxes'." - in e_info.value.message - ) - else: - assert ( - "Use the 'bpolys' parameter to specify the boundaries using a " - "geopandas.GeoDataFrame." in e_info.value.message - ) + + assert ( + "Use the 'bpolys' parameter to specify the boundaries using a " + "geopandas.GeoDataFrame." in e_info.value.message + ) @pytest.mark.vcr diff --git a/ohsome/test/test_helper.py b/ohsome/test/test_helper.py index ca22f8b..bcbd531 100644 --- a/ohsome/test/test_helper.py +++ b/ohsome/test/test_helper.py @@ -3,19 +3,23 @@ """Tests for utility functions""" import datetime +import json import logging import os import numpy as np import pandas as pd import pytest +from shapely import Polygon +from ohsome import OhsomeException from ohsome.helper import ( find_groupby_names, extract_error_message_from_invalid_json, format_time, convert_arrays, format_list_parameters, + format_bpolys, ) script_path = os.path.dirname(os.path.realpath(__file__)) @@ -210,3 +214,24 @@ def test_format_list_parameters(): output = format_list_parameters(method_input) assert output == expected_output + + +def test_format_bpolys(): + """Test if the formatting of bounding polys works correctly.""" + with pytest.raises(OhsomeException) as e: + format_bpolys({}) + assert ( + e.value.message + == "bolys must be a geojson string, a shapely polygonal object or a geopandas object" + ) + + with open(f"{script_path}/data/polygons.geojson") as geojson: + json_str = geojson.read() + assert json.loads(format_bpolys(json_str)) == json.loads(json_str) + + polygon = Polygon(((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0))) + assert format_bpolys(polygon) == ( + '{"type": "FeatureCollection", "features": [{"id": "0", "type": "Feature", ' + '"properties": {}, "geometry": {"type": "Polygon", "coordinates": [[[0.0, ' + "0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0]]]}}]}" + ) From d30edb6c09951f857775da40eed3020b1a0a51bc Mon Sep 17 00:00:00 2001 From: Piero Date: Thu, 16 Nov 2023 13:15:22 +0100 Subject: [PATCH 3/6] files were formatted correctly --- ohsome/clients.py | 1 + ohsome/test/test_client.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ohsome/clients.py b/ohsome/clients.py index 7358324..6ebfcc9 100644 --- a/ohsome/clients.py +++ b/ohsome/clients.py @@ -7,6 +7,7 @@ from pathlib import Path from typing import Union, Optional, List from urllib.parse import urljoin +import datetime as dt import geopandas as gpd import pandas as pd diff --git a/ohsome/test/test_client.py b/ohsome/test/test_client.py index b5d4462..7bcd56d 100644 --- a/ohsome/test/test_client.py +++ b/ohsome/test/test_client.py @@ -17,9 +17,9 @@ logger = logging.getLogger(__name__) + 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 From a3de2e74b6dbe82ac14716285968ce248643a7c9 Mon Sep 17 00:00:00 2001 From: Piero Date: Fri, 17 Nov 2023 13:14:41 +0100 Subject: [PATCH 4/6] test: a test to check if timestamps are returned without timezone in the response for a dataframe and geodataframe --- ohsome/test/test_response.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ohsome/test/test_response.py b/ohsome/test/test_response.py index 3d12952..548038f 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 @@ -361,3 +362,26 @@ def test_empty_geodataframe(base_client): assert isinstance(result, gpd.GeoDataFrame) assert result.empty + + +def test_check_timestamp_groupBy_boundary_and_geometry(base_client): + """Tests whether the format of count.groupBy.Boundary is a timestamp format with timezone""" + input = dt.datetime(2008, 1, 1) + + bbox = "8.67,49.39,8.71,49.42" + time = "2008-01-01/2023-01-01/P1Y" + fltr = "amenity=cafe and type:node" + client = base_client + + response_groupBy = client.elements.count.groupByBoundary.post( + bboxes=bbox, time=time, filter=fltr + ) + result_groupBy = response_groupBy.as_dataframe().index.levels[1][0] + + response_geometry = client.elements.geometry.post( + bboxes=bbox, time=time, filter=fltr + ) + result_geometry = response_geometry.as_dataframe().index.levels[1][0] + + assert result_groupBy == input + assert result_geometry == input From 6a3193842df268a182f54251b9d072429961be63 Mon Sep 17 00:00:00 2001 From: Piero Date: Fri, 17 Nov 2023 15:52:05 +0100 Subject: [PATCH 5/6] test and change: test was written to check if the timestamp for dataframes(geoemtry) and geodataframes(groupByBoundary) is with timezone(UTC). Than the format parameter for every timestamp in the function _as_geodataframe was changed to ISO8601 --- ohsome/response.py | 10 +++++----- ohsome/test/test_response.py | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ohsome/response.py b/ohsome/response.py index ad38d01..98701d7 100644 --- a/ohsome/response.py +++ b/ohsome/response.py @@ -86,16 +86,16 @@ def _as_geodataframe(self, multi_index=True): if "@validFrom" in features.columns: features["@validFrom"] = pd.to_datetime( - features["@validFrom"], format="%Y-%m-%dT%H:%M:%SZ" + features["@validFrom"], format="ISO8601" ) features["@validTo"] = pd.to_datetime( - features["@validTo"], format="%Y-%m-%dT%H:%M:%SZ" + features["@validTo"], 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"], format="ISO8601" ) if multi_index: features = features.set_index(["@osmId", "@snapshotTimestamp"]) @@ -103,13 +103,13 @@ def _as_geodataframe(self, multi_index=True): "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"], 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"], format="ISO8601" ) if multi_index: features = features.set_index(["@timestamp"]) diff --git a/ohsome/test/test_response.py b/ohsome/test/test_response.py index 548038f..e5c453d 100644 --- a/ohsome/test/test_response.py +++ b/ohsome/test/test_response.py @@ -364,9 +364,8 @@ def test_empty_geodataframe(base_client): assert result.empty -def test_check_timestamp_groupBy_boundary_and_geometry(base_client): +def test_check_timestamp_groupBy_boundary_and_geometry_for_user(base_client): """Tests whether the format of count.groupBy.Boundary is a timestamp format with timezone""" - input = dt.datetime(2008, 1, 1) bbox = "8.67,49.39,8.71,49.42" time = "2008-01-01/2023-01-01/P1Y" @@ -383,5 +382,5 @@ def test_check_timestamp_groupBy_boundary_and_geometry(base_client): ) result_geometry = response_geometry.as_dataframe().index.levels[1][0] - assert result_groupBy == input - assert result_geometry == input + assert result_groupBy.tz == dt.timezone.utc + assert result_geometry.tz == dt.timezone.utc From 19d16d96757ea45ad4499a9464356c5a641be48a Mon Sep 17 00:00:00 2001 From: Moritz Schott Date: Fri, 17 Nov 2023 20:36:54 +0100 Subject: [PATCH 6/6] fix: formatting and imports --- ohsome/clients.py | 1 - ohsome/test/test_client.py | 1 - 2 files changed, 2 deletions(-) diff --git a/ohsome/clients.py b/ohsome/clients.py index 6ebfcc9..7358324 100644 --- a/ohsome/clients.py +++ b/ohsome/clients.py @@ -7,7 +7,6 @@ from pathlib import Path from typing import Union, Optional, List from urllib.parse import urljoin -import datetime as dt import geopandas as gpd import pandas as pd diff --git a/ohsome/test/test_client.py b/ohsome/test/test_client.py index 7bcd56d..2235d60 100644 --- a/ohsome/test/test_client.py +++ b/ohsome/test/test_client.py @@ -17,7 +17,6 @@ logger = logging.getLogger(__name__) - 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)