Skip to content

Commit 21f4cb2

Browse files
committed
fix mypy & other comments
2 parents 1dece19 + 65517a8 commit 21f4cb2

File tree

4 files changed

+59
-47
lines changed

4 files changed

+59
-47
lines changed

requirements.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
5-
# pip-compile --cert=None --client-cert=None --index-url=None --pip-args=None requirements.in
5+
# pip-compile --output-file=./requirements.txt --pre ./requirements.in
66
#
7-
asgiref==3.10.0
7+
asgiref~=3.10
88
# via flask
9-
blinker==1.9.0
9+
blinker~=1.9
1010
# via flask
11-
click==8.3.0
11+
click~=8.3
1212
# via flask
13-
flask[async]==3.1.2
13+
flask[async]~=3.1
1414
# via
1515
# -r requirements.in
1616
# flask-cors
@@ -25,13 +25,13 @@ geode-common==33.11.0
2525
# geode-viewables
2626
geode-viewables==3.3.0
2727
# via -r requirements.in
28-
greenlet==3.2.4
28+
greenlet~=3.2
2929
# via sqlalchemy
30-
itsdangerous==2.2.0
30+
itsdangerous~=2.2
3131
# via flask
32-
jinja2==3.1.6
32+
jinja2~=3.1
3333
# via flask
34-
markupsafe==3.0.3
34+
markupsafe~=3.0
3535
# via
3636
# flask
3737
# jinja2
@@ -59,9 +59,9 @@ opengeode-io==7.4.0
5959
# -r requirements.in
6060
# geode-viewables
6161
# opengeode-geosciencesio
62-
sqlalchemy==2.0.43
62+
sqlalchemy~=2.0
6363
# via flask-sqlalchemy
64-
typing-extensions==4.15.0
64+
typing-extensions~=4.15
6565
# via sqlalchemy
6666
werkzeug==3.1.2
6767
# via

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def save_viewable_file():
257257
200,
258258
)
259259

260+
260261
with open(os.path.join(schemas, "texture_coordinates.json"), "r") as file:
261262
texture_coordinates_json = json.load(file)
262263

src/opengeodeweb_back/utils_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def create_data_folder_from_id(data_id: str) -> str:
163163
def save_all_viewables_and_return_info(
164164
geode_object: str,
165165
data: Any,
166-
input_file: str | None = None,
166+
input_file: str | None = None,
167167
additional_files: list[str] | None = None,
168168
) -> dict[str, Any]:
169169
if additional_files is None:

tests/test_create_routes.py

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
11
# Standard library imports
22
import os
3-
from typing import Dict, Any, TypedDict, cast
3+
import uuid
4+
from typing import Any, Callable, Dict, List
45

56
# Third party imports
67
import pytest
8+
from flask.testing import FlaskClient
79

810
# Local application imports
911
from src.opengeodeweb_back import test_utils
1012

11-
# --- Type definitions for test data ---
12-
class Point(TypedDict):
13-
x: float
14-
y: float
15-
16-
class PointData(TypedDict):
17-
name: str
18-
x: float
19-
y: float
20-
z: float
21-
22-
class AOIData(TypedDict):
23-
name: str
24-
points: list[Point]
25-
z: float
26-
27-
# --- Fixtures ---
2813
@pytest.fixture
29-
def point_data() -> PointData:
14+
def point_data() -> Dict[str, Any]:
3015
return {
3116
"name": "test_point",
3217
"x": 1.0,
@@ -35,7 +20,7 @@ def point_data() -> PointData:
3520
}
3621

3722
@pytest.fixture
38-
def aoi_data() -> AOIData:
23+
def aoi_data() -> Dict[str, Any]:
3924
return {
4025
"name": "test_aoi",
4126
"points": [
@@ -47,50 +32,58 @@ def aoi_data() -> AOIData:
4732
"z": 0.0
4833
}
4934

50-
# --- Tests ---
51-
def test_create_point(client: Any, point_data: PointData) -> None:
35+
def test_create_point(client: FlaskClient, point_data: Dict[str, Any]) -> None:
5236
"""Test the creation of a point with valid data."""
5337
route: str = "/opengeodeweb_back/create/create_point"
38+
5439
# Test with all required data
5540
response = client.post(route, json=point_data)
5641
assert response.status_code == 200
42+
5743
# Verify response data
58-
response_data: Dict[str, Any] = response.json
44+
response_data: Any = response.json
5945
assert "viewable_file_name" in response_data
6046
assert "id" in response_data
6147
assert "name" in response_data
6248
assert "native_file_name" in response_data
6349
assert "object_type" in response_data
6450
assert "geode_object" in response_data
51+
6552
assert response_data["name"] == point_data["name"]
6653
assert response_data["object_type"] == "mesh"
6754
assert response_data["geode_object"] == "PointSet3D"
68-
# Test with missing parameters - IMPORTANT: use .copy() to avoid mutation
55+
56+
# Test with missing parameters
6957
test_utils.test_route_wrong_params(client, route, lambda: point_data.copy()) # type: ignore
7058

71-
def test_create_aoi(client: Any, aoi_data: AOIData) -> None:
59+
def test_create_aoi(client: FlaskClient, aoi_data: Dict[str, Any]) -> None:
7260
"""Test the creation of an AOI with valid data."""
7361
route: str = "/opengeodeweb_back/create/create_aoi"
62+
7463
# Test with all required data
7564
response = client.post(route, json=aoi_data)
7665
assert response.status_code == 200
66+
7767
# Verify response data
78-
response_data: Dict[str, Any] = response.json
68+
response_data: Any = response.json
7969
assert "viewable_file_name" in response_data
8070
assert "id" in response_data
8171
assert "name" in response_data
8272
assert "native_file_name" in response_data
8373
assert "object_type" in response_data
8474
assert "geode_object" in response_data
75+
8576
assert response_data["name"] == aoi_data["name"]
8677
assert response_data["object_type"] == "mesh"
8778
assert response_data["geode_object"] == "EdgedCurve3D"
88-
# Test with missing parameters - IMPORTANT: use .copy() to avoid mutation
89-
test_utils.test_route_wrong_params(client, route, lambda: aoi_data.copy()) # type: ignore
9079

91-
def test_create_point_with_invalid_data(client: Any) -> None:
80+
# Test with missing parameters
81+
test_utils.test_route_wrong_params(client, route, lambda: aoi_data.copy())# type: ignore
82+
83+
def test_create_point_with_invalid_data(client: FlaskClient) -> None:
9284
"""Test the point creation endpoint with invalid data."""
9385
route: str = "/opengeodeweb_back/create/create_point"
86+
9487
# Test with non-numeric coordinates
9588
invalid_data: Dict[str, Any] = {
9689
"name": "invalid_point",
@@ -100,6 +93,7 @@ def test_create_point_with_invalid_data(client: Any) -> None:
10093
}
10194
response = client.post(route, json=invalid_data)
10295
assert response.status_code == 400
96+
10397
# Test with missing coordinates
10498
invalid_data = {
10599
"name": "invalid_point",
@@ -109,9 +103,10 @@ def test_create_point_with_invalid_data(client: Any) -> None:
109103
response = client.post(route, json=invalid_data)
110104
assert response.status_code == 400
111105

112-
def test_create_aoi_with_invalid_data(client: Any, aoi_data: AOIData) -> None:
106+
def test_create_aoi_with_invalid_data(client: FlaskClient, aoi_data: Dict[str, Any]) -> None:
113107
"""Test the AOI creation endpoint with invalid data."""
114108
route: str = "/opengeodeweb_back/create/create_aoi"
109+
115110
# Test with invalid points
116111
invalid_data: Dict[str, Any] = {
117112
**aoi_data,
@@ -124,6 +119,7 @@ def test_create_aoi_with_invalid_data(client: Any, aoi_data: AOIData) -> None:
124119
}
125120
response = client.post(route, json=invalid_data)
126121
assert response.status_code == 400
122+
127123
# Test with too few points
128124
invalid_data = {
129125
**aoi_data,
@@ -134,6 +130,7 @@ def test_create_aoi_with_invalid_data(client: Any, aoi_data: AOIData) -> None:
134130
}
135131
response = client.post(route, json=invalid_data)
136132
assert response.status_code == 400
133+
137134
# Test with invalid z value
138135
invalid_data = {
139136
**aoi_data,
@@ -142,58 +139,72 @@ def test_create_aoi_with_invalid_data(client: Any, aoi_data: AOIData) -> None:
142139
response = client.post(route, json=invalid_data)
143140
assert response.status_code == 400
144141

145-
def test_create_point_file_generation(client: Any, point_data: PointData) -> None:
142+
def test_create_point_file_generation(client: FlaskClient, point_data: Dict[str, Any]) -> None:
146143
"""Test that the point creation generates the correct files."""
147144
route: str = "/opengeodeweb_back/create/create_point"
145+
148146
# Make the request
149147
response = client.post(route, json=point_data)
150148
assert response.status_code == 200
151-
response_data: Dict[str, Any] = response.json
149+
response_data: Any = response.json
150+
152151
# Get the data folder path for this specific ID
153152
DATA_FOLDER_PATH: str = client.application.config["DATA_FOLDER_PATH"]
154153
data_id: str = response_data["id"]
155154
data_folder: str = os.path.join(DATA_FOLDER_PATH, data_id)
155+
156156
# Check that the data folder exists
157157
assert os.path.exists(data_folder)
158158
assert os.path.isdir(data_folder)
159+
159160
# Check native file exists
160161
native_file_path: str = os.path.join(data_folder, response_data["native_file_name"])
161162
assert os.path.exists(native_file_path)
163+
162164
# Check viewable file exists
163165
viewable_file_path: str = os.path.join(data_folder, response_data["viewable_file_name"])
164166
assert os.path.exists(viewable_file_path)
167+
165168
# Check light viewable file exists if present
166169
if "binary_light_viewable" in response_data:
167170
light_viewable_file_path: str = os.path.join(data_folder, "light_viewable.vtp")
168171
assert os.path.exists(light_viewable_file_path)
172+
169173
# Verify file extensions
170174
assert response_data["native_file_name"].endswith(".og_pts3d")
171175
assert response_data["viewable_file_name"].endswith(".vtp")
172176

173-
def test_create_aoi_file_generation(client: Any, aoi_data: AOIData) -> None:
177+
def test_create_aoi_file_generation(client: FlaskClient, aoi_data: Dict[str, Any]) -> None:
174178
"""Test that the AOI creation generates the correct files."""
175179
route: str = "/opengeodeweb_back/create/create_aoi"
180+
176181
# Make the request
177182
response = client.post(route, json=aoi_data)
178183
assert response.status_code == 200
179-
response_data: Dict[str, Any] = response.json
184+
response_data: Any = response.json
185+
180186
# Get the data folder path for this specific ID
181187
DATA_FOLDER_PATH: str = client.application.config["DATA_FOLDER_PATH"]
182188
data_id: str = response_data["id"]
183189
data_folder: str = os.path.join(DATA_FOLDER_PATH, data_id)
190+
184191
# Check that the data folder exists
185192
assert os.path.exists(data_folder)
186193
assert os.path.isdir(data_folder)
194+
187195
# Check native file exists
188196
native_file_path: str = os.path.join(data_folder, response_data["native_file_name"])
189197
assert os.path.exists(native_file_path)
198+
190199
# Check viewable file exists
191200
viewable_file_path: str = os.path.join(data_folder, response_data["viewable_file_name"])
192201
assert os.path.exists(viewable_file_path)
202+
193203
# Check light viewable file exists if present
194204
if "binary_light_viewable" in response_data:
195205
light_viewable_file_path: str = os.path.join(data_folder, "light_viewable.vtp")
196206
assert os.path.exists(light_viewable_file_path)
207+
197208
# Verify file extensions
198209
assert response_data["native_file_name"].endswith(".og_edc3d")
199-
assert response_data["viewable_file_name"].endswith(".vtp")
210+
assert response_data["viewable_file_name"].endswith(".vtp")

0 commit comments

Comments
 (0)