From 51d4427bdd22a69c8cf92ccd64b25f839c6e3423 Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Wed, 27 Nov 2024 12:25:48 +0000 Subject: [PATCH 1/2] Apply prepare changes --- src/opengeodeweb_back/geode_objects.py | 1 + src/opengeodeweb_back/routes/blueprint_routes.py | 9 +++++++-- src/opengeodeweb_back/test_utils.py | 8 +++++--- tests/test_routes.py | 11 ++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/opengeodeweb_back/geode_objects.py b/src/opengeodeweb_back/geode_objects.py index 03007cad..77d2ac30 100644 --- a/src/opengeodeweb_back/geode_objects.py +++ b/src/opengeodeweb_back/geode_objects.py @@ -10,6 +10,7 @@ # Local application imports + def geode_objects_dict(): return { "BRep": { diff --git a/src/opengeodeweb_back/routes/blueprint_routes.py b/src/opengeodeweb_back/routes/blueprint_routes.py index a49993de..9074afb0 100644 --- a/src/opengeodeweb_back/routes/blueprint_routes.py +++ b/src/opengeodeweb_back/routes/blueprint_routes.py @@ -310,6 +310,7 @@ def create_point(): ) as file: vertex_attribute_names_json = json.load(file) + @routes.route( vertex_attribute_names_json["route"], methods=vertex_attribute_names_json["methods"], @@ -318,8 +319,12 @@ def vertex_attribute_names(): UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"] utils_functions.validate_request(flask.request, vertex_attribute_names_json) - file_absolute_path = os.path.join(UPLOAD_FOLDER, werkzeug.utils.secure_filename(flask.request.json["filename"])) - data = geode_functions.load(flask.request.json["input_geode_object"], file_absolute_path) + file_absolute_path = os.path.join( + UPLOAD_FOLDER, werkzeug.utils.secure_filename(flask.request.json["filename"]) + ) + data = geode_functions.load( + flask.request.json["input_geode_object"], file_absolute_path + ) vertex_attribute_names = data.vertex_attribute_manager().attribute_names() print(f"vertex_attribute_names: {vertex_attribute_names}", flush=True) return flask.make_response( diff --git a/src/opengeodeweb_back/test_utils.py b/src/opengeodeweb_back/test_utils.py index 75329ea6..0d4c6176 100644 --- a/src/opengeodeweb_back/test_utils.py +++ b/src/opengeodeweb_back/test_utils.py @@ -13,11 +13,13 @@ def test_route_wrong_params(client, route, get_full_data): assert response.status_code == 400 error_description = response.json["description"] assert error_description == f"Validation error: '{key}' is a required property" - + json = get_full_data() json["dumb_key"] = "dumb_value" response = client.post(route, json=json) assert response.status_code == 400 error_description = response.json["description"] - assert error_description == "Validation error: Additional properties are not allowed ('dumb_key' was unexpected)" - \ No newline at end of file + assert ( + error_description + == "Validation error: Additional properties are not allowed ('dumb_key' was unexpected)" + ) diff --git a/tests/test_routes.py b/tests/test_routes.py index 7ebf4d99..970606c2 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -44,6 +44,7 @@ def get_full_data(): # Test all params test_utils.test_route_wrong_params(client, route, get_full_data) + def test_upload_file(client): response = client.put( f"/upload_file", @@ -63,7 +64,7 @@ def get_full_data(): } json = get_full_data() - response = client.post(route,json=json) + response = client.post(route, json=json) assert response.status_code == 200 has_missing_files = response.json["has_missing_files"] mandatory_files = response.json["mandatory_files"] @@ -75,6 +76,7 @@ def get_full_data(): # Test all params test_utils.test_route_wrong_params(client, route, get_full_data) + def test_geographic_coordinate_systems(client): route = f"/geographic_coordinate_systems" get_full_data = lambda: {"input_geode_object": "BRep"} @@ -89,8 +91,9 @@ def test_geographic_coordinate_systems(client): # Test all params test_utils.test_route_wrong_params(client, route, get_full_data) + def test_inspect_file(client): - route = f"/inspect_file" + route = f"/inspect_file" def get_full_data(): return { @@ -109,6 +112,7 @@ def get_full_data(): # Test all params test_utils.test_route_wrong_params(client, route, get_full_data) + def test_geode_objects_and_output_extensions(client): route = "/geode_objects_and_output_extensions" @@ -159,6 +163,7 @@ def get_full_data(): # Test all params test_utils.test_route_wrong_params(client, route, get_full_data) + def test_vertex_attribute_names(client): response = client.put( f"/upload_file", @@ -197,5 +202,5 @@ def test_create_point(client): id = response.json["id"] assert type(id) is str - # Test all params + # Test all params test_utils.test_route_wrong_params(client, route, get_full_data) From 3fa88cd2746df819ac80d4437966f0ec2ca18ec1 Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Thu, 28 Nov 2024 14:30:34 +0000 Subject: [PATCH 2/2] Apply prepare changes --- src/opengeodeweb_back/routes/blueprint_routes.py | 2 +- tests/test_routes.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opengeodeweb_back/routes/blueprint_routes.py b/src/opengeodeweb_back/routes/blueprint_routes.py index 25a1e949..47bb4ab9 100644 --- a/src/opengeodeweb_back/routes/blueprint_routes.py +++ b/src/opengeodeweb_back/routes/blueprint_routes.py @@ -326,7 +326,7 @@ def vertex_attribute_names(): flask.request.json["input_geode_object"], file_absolute_path ) vertex_attribute_names = data.vertex_attribute_manager().attribute_names() - + return flask.make_response( { "vertex_attribute_names": vertex_attribute_names, diff --git a/tests/test_routes.py b/tests/test_routes.py index 19eb2022..138cd435 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -172,6 +172,7 @@ def test_vertex_attribute_names(client): assert response.status_code == 201 route = f"/vertex_attribute_names" + def get_full_data(): return { "input_geode_object": "PolygonalSurface3D",