|
6 | 6 | from werkzeug.datastructures import FileStorage |
7 | 7 |
|
8 | 8 | # Local application imports |
9 | | -from src.opengeodeweb_back import geode_functions, geode_objects, test_utils |
| 9 | +from src.opengeodeweb_back import geode_functions, test_utils |
10 | 10 | from src.opengeodeweb_back.data import Data |
11 | 11 | from src.opengeodeweb_back.database import database |
12 | 12 |
|
@@ -201,113 +201,75 @@ def test_texture_coordinates(client, test_id): |
201 | 201 |
|
202 | 202 | def test_vertex_attribute_names(client, test_id): |
203 | 203 | route = f"/vertex_attribute_names" |
204 | | - for geode_object, value in geode_objects.geode_objects_dict().items(): |
205 | | - if value["object_type"] == "mesh": |
206 | | - input_extensions = geode_functions.geode_object_input_extensions( |
207 | | - geode_object |
208 | | - ) |
209 | | - if "elements" in value: |
210 | | - elements = geode_functions.get_elements(geode_object) |
211 | | - if "points" in elements: |
212 | | - for input_extension in input_extensions: |
213 | | - if ( |
214 | | - geode_functions.is_loadable( |
215 | | - geode_object, |
216 | | - os.path.join("./data", f"test.{input_extension}"), |
217 | | - ) |
218 | | - > 0.0 |
219 | | - ): |
220 | | - |
221 | | - def get_full_data(): |
222 | | - return { |
223 | | - "id": test_id, |
224 | | - } |
225 | | - |
226 | | - response = client.post(route, json=get_full_data()) |
227 | | - assert response.status_code == 200 |
228 | | - vertex_attribute_names = response.json[ |
229 | | - "vertex_attribute_names" |
230 | | - ] |
231 | | - assert type(vertex_attribute_names) is list |
232 | | - for vertex_attribute_name in vertex_attribute_names: |
233 | | - assert type(vertex_attribute_name) is str |
| 204 | + |
| 205 | + with client.application.app_context(): |
| 206 | + data = Data.create( |
| 207 | + name="test_mesh", |
| 208 | + geode_object="PolygonalSurface3D", |
| 209 | + input_file="test.vtp" |
| 210 | + ) |
| 211 | + data.native_file_name = "test.vtp" |
| 212 | + database.session.commit() |
234 | 213 |
|
235 | | - # Test all params |
236 | | - test_utils.test_route_wrong_params(client, route, get_full_data) |
| 214 | + data_path = geode_functions.data_file_path(data.id, "test.vtp") |
| 215 | + os.makedirs(os.path.dirname(data_path), exist_ok=True) |
| 216 | + if os.path.exists("./tests/data/hat.vtp"): |
| 217 | + shutil.copy("./tests/data/hat.vtp", data_path) |
| 218 | + |
| 219 | + response = client.post(route, json={"id": data.id}) |
| 220 | + assert response.status_code == 200 |
| 221 | + vertex_attribute_names = response.json["vertex_attribute_names"] |
| 222 | + assert type(vertex_attribute_names) is list |
| 223 | + for vertex_attribute_name in vertex_attribute_names: |
| 224 | + assert type(vertex_attribute_name) is str |
237 | 225 |
|
238 | 226 |
|
239 | 227 | def test_polygon_attribute_names(client, test_id): |
240 | 228 | route = f"/polygon_attribute_names" |
241 | | - for geode_object, value in geode_objects.geode_objects_dict().items(): |
242 | | - if value["object_type"] == "mesh": |
243 | | - input_extensions = geode_functions.geode_object_input_extensions( |
244 | | - geode_object |
245 | | - ) |
246 | | - if "elements" in value: |
247 | | - elements = geode_functions.get_elements(geode_object) |
248 | | - if "polygons" in elements: |
249 | | - for input_extension in input_extensions: |
250 | | - if ( |
251 | | - geode_functions.is_loadable( |
252 | | - geode_object, |
253 | | - os.path.join("./data", f"test.{input_extension}"), |
254 | | - ) |
255 | | - > 0.0 |
256 | | - ): |
257 | | - |
258 | | - def get_full_data(): |
259 | | - return { |
260 | | - "id": test_id, |
261 | | - } |
262 | | - |
263 | | - response = client.post(route, json=get_full_data()) |
264 | | - assert response.status_code == 200 |
265 | | - polygon_attribute_names = response.json[ |
266 | | - "polygon_attribute_names" |
267 | | - ] |
268 | | - assert type(polygon_attribute_names) is list |
269 | | - for polygon_attribute_name in polygon_attribute_names: |
270 | | - assert type(polygon_attribute_name) is str |
| 229 | + |
| 230 | + with client.application.app_context(): |
| 231 | + data = Data.create( |
| 232 | + name="test_mesh", |
| 233 | + geode_object="PolygonalSurface3D", |
| 234 | + input_file="test.vtp" |
| 235 | + ) |
| 236 | + data.native_file_name = "test.vtp" |
| 237 | + database.session.commit() |
271 | 238 |
|
272 | | - # Test all params |
273 | | - test_utils.test_route_wrong_params(client, route, get_full_data) |
| 239 | + data_path = geode_functions.data_file_path(data.id, "test.vtp") |
| 240 | + os.makedirs(os.path.dirname(data_path), exist_ok=True) |
| 241 | + shutil.copy("./tests/data/test.vtp", data_path) |
| 242 | + |
| 243 | + response = client.post(route, json={"id": data.id}) |
| 244 | + assert response.status_code == 200 |
| 245 | + polygon_attribute_names = response.json["polygon_attribute_names"] |
| 246 | + assert type(polygon_attribute_names) is list |
| 247 | + for polygon_attribute_name in polygon_attribute_names: |
| 248 | + assert type(polygon_attribute_name) is str |
274 | 249 |
|
275 | 250 |
|
276 | 251 | def test_polyhedron_attribute_names(client, test_id): |
277 | 252 | route = f"/polyhedron_attribute_names" |
278 | | - for geode_object, value in geode_objects.geode_objects_dict().items(): |
279 | | - if value["object_type"] == "mesh": |
280 | | - input_extensions = geode_functions.geode_object_input_extensions( |
281 | | - geode_object |
282 | | - ) |
283 | | - if "elements" in value: |
284 | | - elements = geode_functions.get_elements(geode_object) |
285 | | - if "polyhedrons" in elements: |
286 | | - for input_extension in input_extensions: |
287 | | - if ( |
288 | | - geode_functions.is_loadable( |
289 | | - geode_object, |
290 | | - os.path.join("./data", f"test.{input_extension}"), |
291 | | - ) |
292 | | - > 0.0 |
293 | | - ): |
294 | | - |
295 | | - def get_full_data(): |
296 | | - return { |
297 | | - "id": test_id, |
298 | | - } |
299 | | - |
300 | | - response = client.post(route, json=get_full_data()) |
301 | | - assert response.status_code == 200 |
302 | | - polyhedron_attribute_names = response.json[ |
303 | | - "polyhedron_attribute_names" |
304 | | - ] |
305 | | - assert type(polyhedron_attribute_names) is list |
306 | | - for polyhedron_attribute_name in polyhedron_attribute_names: |
307 | | - assert type(polyhedron_attribute_name) is str |
| 253 | + |
| 254 | + with client.application.app_context(): |
| 255 | + data = Data.create( |
| 256 | + name="test_mesh", |
| 257 | + geode_object="PolyhedralSolid3D", |
| 258 | + input_file="test.vtu" |
| 259 | + ) |
| 260 | + data.native_file_name = "test.vtu" |
| 261 | + database.session.commit() |
308 | 262 |
|
309 | | - # Test all params |
310 | | - test_utils.test_route_wrong_params(client, route, get_full_data) |
| 263 | + data_path = geode_functions.data_file_path(data.id, "test.vtu") |
| 264 | + os.makedirs(os.path.dirname(data_path), exist_ok=True) |
| 265 | + shutil.copy("./tests/data/test.vtu", data_path) |
| 266 | + |
| 267 | + response = client.post(route, json={"id": data.id}) |
| 268 | + assert response.status_code == 200 |
| 269 | + polyhedron_attribute_names = response.json["polyhedron_attribute_names"] |
| 270 | + assert type(polyhedron_attribute_names) is list |
| 271 | + for polyhedron_attribute_name in polyhedron_attribute_names: |
| 272 | + assert type(polyhedron_attribute_name) is str |
311 | 273 |
|
312 | 274 |
|
313 | 275 | def test_create_point(client): |
|
0 commit comments