@@ -91,33 +91,26 @@ def test_create_aoi(client: FlaskClient, aoi_data: Dict[str, Any]) -> None:
9191 # Test with missing parameters
9292 test_utils .test_route_wrong_params (client , route , lambda : aoi_data .copy ()) # type: ignore
9393
94-
95- def test_create_voi (client : FlaskClient , voi_data : Dict [str , Any ]) -> None :
94+ def test_create_voi (client : FlaskClient , aoi_data : Dict [str , Any ], voi_data : Dict [str , Any ]) -> None :
9695 """Test the creation of a VOI with valid data (including optional id)."""
97- route : str = "/opengeodeweb_back/create/create_voi"
96+ aoi_route = "/opengeodeweb_back/create/create_aoi"
97+ aoi_response = client .post (aoi_route , json = aoi_data )
98+ assert aoi_response .status_code == 200
99+ aoi_id = aoi_response .json ["id" ]
100+
101+ voi_data ["aoi_id" ] = aoi_id
98102
99- response = client .post (route , json = voi_data )
103+ voi_route = "/opengeodeweb_back/create/create_voi"
104+ response = client .post (voi_route , json = voi_data )
100105 assert response .status_code == 200
101106
102- response_data : Any = response .json
107+ response_data = response .json
103108 assert "id" in response_data
104109 assert "name" in response_data
105110 assert response_data ["name" ] == voi_data ["name" ]
106111 assert response_data ["object_type" ] == "mesh"
107112 assert response_data ["geode_object" ] == "EdgedCurve3D"
108113
109- voi_data_no_id = voi_data .copy ()
110- del voi_data_no_id ["id" ]
111- response = client .post (route , json = voi_data_no_id )
112- assert response .status_code == 200
113- assert response .json ["name" ] == voi_data ["name" ]
114-
115- voi_data_required_only = voi_data .copy ()
116- del voi_data_required_only ["id" ]
117-
118- test_utils .test_route_wrong_params (client , route , lambda : voi_data_required_only .copy ()) # type: ignore
119-
120-
121114def test_create_point_with_invalid_data (client : FlaskClient ) -> None :
122115 """Test the point creation endpoint with invalid data."""
123116 route : str = "/opengeodeweb_back/create/create_point"
@@ -144,7 +137,6 @@ def test_create_aoi_with_invalid_data(
144137 """Test the AOI creation endpoint with invalid data."""
145138 route : str = "/opengeodeweb_back/create/create_aoi"
146139
147- # Test with invalid points
148140 invalid_data : Dict [str , Any ] = {
149141 ** aoi_data ,
150142 "points" : [
@@ -157,154 +149,34 @@ def test_create_aoi_with_invalid_data(
157149 response = client .post (route , json = invalid_data )
158150 assert response .status_code == 400
159151
160- # Test with too few points
161152 invalid_data = {** aoi_data , "points" : [{"x" : 0.0 , "y" : 0.0 }, {"x" : 1.0 , "y" : 0.0 }]}
162153 response = client .post (route , json = invalid_data )
163154 assert response .status_code == 400
164155
165- # Test with invalid z value
166156 invalid_data = {** aoi_data , "z" : "not_a_number" }
167157 response = client .post (route , json = invalid_data )
168158 assert response .status_code == 400
169159
170160
171161def test_create_voi_with_invalid_data (
172- client : FlaskClient , voi_data : Dict [str , Any ]
162+ client : FlaskClient , aoi_data : Dict [ str , Any ], voi_data : Dict [str , Any ]
173163) -> None :
174164 """Test the VOI creation endpoint with invalid data."""
175- route : str = "/opengeodeweb_back/create/create_voi"
165+ aoi_route = "/opengeodeweb_back/create/create_aoi"
166+ aoi_response = client .post (aoi_route , json = aoi_data )
167+ assert aoi_response .status_code == 200
168+ aoi_id = aoi_response .json ["id" ]
169+
170+ route = "/opengeodeweb_back/create/create_aoi"
176171
177- # Test with non-numeric z_min
178- invalid_data : Dict [str , Any ] = {** voi_data , "z_min" : "not_a_number" }
172+ invalid_data = {** voi_data , "aoi_id" : aoi_id , "z_min" : "not_a_number" }
179173 response = client .post (route , json = invalid_data )
180174 assert response .status_code == 400
181175
182- # Test with non-numeric z_max
183- invalid_data = {** voi_data , "z_max" : "not_a_number" }
176+ invalid_data = {** voi_data , "aoi_id" : aoi_id , "z_max" : "not_a_number" }
184177 response = client .post (route , json = invalid_data )
185178 assert response .status_code == 400
186179
187- # Test with invalid aoi_id format (e.g., not a string/uuid)
188180 invalid_data = {** voi_data , "aoi_id" : 12345 }
189181 response = client .post (route , json = invalid_data )
190- assert response .status_code == 400
191-
192-
193- def test_create_point_file_generation (
194- client : FlaskClient , point_data : Dict [str , Any ]
195- ) -> None :
196- """Test that the point creation generates the correct files."""
197- route : str = "/opengeodeweb_back/create/create_point"
198-
199- # Make the request
200- response = client .post (route , json = point_data )
201- assert response .status_code == 200
202- response_data : Any = response .json
203-
204- # Get the data folder path for this specific ID
205- DATA_FOLDER_PATH : str = client .application .config ["DATA_FOLDER_PATH" ]
206- data_id : str = response_data ["id" ]
207- data_folder : str = os .path .join (DATA_FOLDER_PATH , data_id )
208-
209- # Check that the data folder exists
210- assert os .path .exists (data_folder )
211- assert os .path .isdir (data_folder )
212-
213- # Check native file exists
214- native_file_path : str = os .path .join (data_folder , response_data ["native_file_name" ])
215- assert os .path .exists (native_file_path )
216-
217- # Check viewable file exists
218- viewable_file_path : str = os .path .join (
219- data_folder , response_data ["viewable_file_name" ]
220- )
221- assert os .path .exists (viewable_file_path )
222-
223- # Check light viewable file exists if present
224- if "binary_light_viewable" in response_data :
225- light_viewable_file_path : str = os .path .join (data_folder , "light_viewable.vtp" )
226- assert os .path .exists (light_viewable_file_path )
227-
228- # Verify file extensions
229- assert response_data ["native_file_name" ].endswith (".og_pts3d" )
230- assert response_data ["viewable_file_name" ].endswith (".vtp" )
231-
232-
233- def test_create_aoi_file_generation (
234- client : FlaskClient , aoi_data : Dict [str , Any ]
235- ) -> None :
236- """Test that the AOI creation generates the correct files."""
237- route : str = "/opengeodeweb_back/create/create_aoi"
238-
239- # Make the request
240- response = client .post (route , json = aoi_data )
241- assert response .status_code == 200
242- response_data : Any = response .json
243-
244- # Get the data folder path for this specific ID
245- DATA_FOLDER_PATH : str = client .application .config ["DATA_FOLDER_PATH" ]
246- data_id : str = response_data ["id" ]
247- data_folder : str = os .path .join (DATA_FOLDER_PATH , data_id )
248-
249- # Check that the data folder exists
250- assert os .path .exists (data_folder )
251- assert os .path .isdir (data_folder )
252-
253- # Check native file exists
254- native_file_path : str = os .path .join (data_folder , response_data ["native_file_name" ])
255- assert os .path .exists (native_file_path )
256-
257- # Check viewable file exists
258- viewable_file_path : str = os .path .join (
259- data_folder , response_data ["viewable_file_name" ]
260- )
261- assert os .path .exists (viewable_file_path )
262-
263- # Check light viewable file exists if present
264- if "binary_light_viewable" in response_data :
265- light_viewable_file_path : str = os .path .join (data_folder , "light_viewable.vtp" )
266- assert os .path .exists (light_viewable_file_path )
267-
268- # Verify file extensions
269- assert response_data ["native_file_name" ].endswith (".og_edc3d" )
270- assert response_data ["viewable_file_name" ].endswith (".vtp" )
271-
272-
273- def test_create_voi_file_generation (
274- client : FlaskClient , voi_data : Dict [str , Any ]
275- ) -> None :
276- """Test that the VOI creation generates the correct files."""
277- route : str = "/opengeodeweb_back/create/create_voi"
278-
279- # Make the request
280- response = client .post (route , json = voi_data )
281- assert response .status_code == 200
282- response_data : Any = response .json
283-
284- # Get the data folder path for this specific ID
285- DATA_FOLDER_PATH : str = client .application .config ["DATA_FOLDER_PATH" ]
286- data_id : str = response_data ["id" ]
287- data_folder : str = os .path .join (DATA_FOLDER_PATH , data_id )
288-
289- # Check that the data folder exists
290- assert os .path .exists (data_folder )
291- assert os .path .isdir (data_folder )
292-
293- # Check native file exists
294- native_file_path : str = os .path .join (data_folder , response_data ["native_file_name" ])
295- assert os .path .exists (native_file_path )
296-
297- # Check viewable file exists
298- viewable_file_path : str = os .path .join (
299- data_folder , response_data ["viewable_file_name" ]
300- )
301- assert os .path .exists (viewable_file_path )
302-
303- # Check light viewable file exists if present
304- if "binary_light_viewable" in response_data :
305- light_viewable_file_path : str = os .path .join (data_folder , "light_viewable.vtp" )
306- assert os .path .exists (light_viewable_file_path )
307-
308- # Verify file extensions (VOI uses EdgedCurve3D like AOI)
309- assert response_data ["native_file_name" ].endswith (".og_edc3d" )
310- assert response_data ["viewable_file_name" ].endswith (".vtp" )
182+ assert response .status_code == 400
0 commit comments