From 092789a2a11f84737a5e0db14094876f19537f06 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 19 Feb 2026 14:43:22 +0100 Subject: [PATCH 1/5] feat(structuralModel): Recursive test_route_wrong_params --- src/opengeodeweb_back/test_utils.py | 39 +++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/opengeodeweb_back/test_utils.py b/src/opengeodeweb_back/test_utils.py index f890989f..b1fac668 100644 --- a/src/opengeodeweb_back/test_utils.py +++ b/src/opengeodeweb_back/test_utils.py @@ -10,21 +10,34 @@ def test_route_wrong_params( - client: FlaskClient, route: str, get_full_data: Callable[[], JsonData] + client: FlaskClient, route: str, get_full_data: Callable[[], JsonData], path: list = [] ) -> None: - for key, value in get_full_data().items(): + def get_json(): json = get_full_data() - json.pop(key) + target = json + for p in path: + target = target[p] + return json, target + + data = get_json()[1] + if isinstance(data, dict): + for key, value in data.items(): + json, target = get_json() + target.pop(key) + response = client.post(route, json=json) + if response.status_code == 400: + error_description = response.get_json()["description"] + assert "must contain" in error_description + assert f"'{key}'" in error_description + if isinstance(value, (dict, list)): + test_route_wrong_params(client, route, get_full_data, path + [key]) + + json, target = get_json() + target["dumb_key"] = "dumb_value" response = client.post(route, json=json) assert response.status_code == 400 error_description = response.get_json()["description"] - assert "data must contain" in error_description - assert f"'{key}'" in error_description - - json = get_full_data() - json["dumb_key"] = "dumb_value" - response = client.post(route, json=json) - assert response.status_code == 400 - error_description = response.get_json()["description"] - assert "data must not contain" in error_description - assert "'dumb_key'" in error_description + assert "must not contain" in error_description + assert "'dumb_key'" in error_description + elif isinstance(data, list) and data: + test_route_wrong_params(client, route, get_full_data, path + [0]) From a905d884c8eb7c7950afb9373684c7f2430c0d3b Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Thu, 19 Feb 2026 13:54:07 +0000 Subject: [PATCH 2/5] Apply prepare changes --- requirements.txt | 1 - src/opengeodeweb_back/test_utils.py | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 15e1ad30..158e1f59 100644 --- a/requirements.txt +++ b/requirements.txt @@ -60,4 +60,3 @@ werkzeug==3.1.2 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.0.14 diff --git a/src/opengeodeweb_back/test_utils.py b/src/opengeodeweb_back/test_utils.py index b1fac668..e95fd903 100644 --- a/src/opengeodeweb_back/test_utils.py +++ b/src/opengeodeweb_back/test_utils.py @@ -10,7 +10,10 @@ def test_route_wrong_params( - client: FlaskClient, route: str, get_full_data: Callable[[], JsonData], path: list = [] + client: FlaskClient, + route: str, + get_full_data: Callable[[], JsonData], + path: list = [], ) -> None: def get_json(): json = get_full_data() From ff911fb17e23a8acb4af62fe64d77d71ed8d62c7 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 19 Feb 2026 15:04:44 +0100 Subject: [PATCH 3/5] mypy ? --- src/opengeodeweb_back/test_utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/opengeodeweb_back/test_utils.py b/src/opengeodeweb_back/test_utils.py index b1fac668..f7dc7137 100644 --- a/src/opengeodeweb_back/test_utils.py +++ b/src/opengeodeweb_back/test_utils.py @@ -10,11 +10,17 @@ def test_route_wrong_params( - client: FlaskClient, route: str, get_full_data: Callable[[], JsonData], path: list = [] + client: FlaskClient, + route: str, + get_full_data: Callable[[], JsonData], + path: list[str | int] | None = None, ) -> None: - def get_json(): + if path is None: + path = [] + + def get_json() -> tuple[JsonData, Any]: json = get_full_data() - target = json + target: Any = json for p in path: target = target[p] return json, target @@ -26,7 +32,7 @@ def get_json(): target.pop(key) response = client.post(route, json=json) if response.status_code == 400: - error_description = response.get_json()["description"] + error_description: str = response.get_json()["description"] assert "must contain" in error_description assert f"'{key}'" in error_description if isinstance(value, (dict, list)): From f51bec93a43b5e3f2b39b9d416bc0e7a306ff38d Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 19 Feb 2026 15:16:10 +0100 Subject: [PATCH 4/5] sub_path --- src/opengeodeweb_back/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengeodeweb_back/test_utils.py b/src/opengeodeweb_back/test_utils.py index f7dc7137..44102e41 100644 --- a/src/opengeodeweb_back/test_utils.py +++ b/src/opengeodeweb_back/test_utils.py @@ -21,8 +21,8 @@ def test_route_wrong_params( def get_json() -> tuple[JsonData, Any]: json = get_full_data() target: Any = json - for p in path: - target = target[p] + for sub_path in path: + target = target[sub_path] return json, target data = get_json()[1] From 34cc4790b7dc9b298fce36e5e9701418d1e856c3 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Feb 2026 13:49:02 +0100 Subject: [PATCH 5/5] trigger release