|
11 | 11 | from opengeodeweb_back import geode_functions |
12 | 12 | from opengeodeweb_back.geode_objects.geode_brep import GeodeBRep |
13 | 13 |
|
14 | | -base_dir = os.path.abspath(os.path.dirname(__file__)) |
15 | | -data_dir = os.path.join(base_dir, "data") |
16 | | - |
17 | 14 |
|
18 | | -def test_model_mesh_components(client: FlaskClient, test_id: str) -> None: |
19 | | - route = "/opengeodeweb_back/models/vtm_component_indices" |
20 | | - |
21 | | - with client.application.app_context(): |
22 | | - data_path = geode_functions.data_file_path(test_id, "viewable.vtm") |
23 | | - os.makedirs(os.path.dirname(data_path), exist_ok=True) |
24 | | - shutil.copy(os.path.join(data_dir, "cube.vtm"), data_path) |
25 | | - |
26 | | - response = client.post(route, json={"id": test_id}) |
27 | | - assert response.status_code == 200 |
| 15 | +from .test_routes import test_save_viewable_file |
28 | 16 |
|
29 | | - uuid_dict = response.get_json()["uuid_to_flat_index"] |
30 | | - assert isinstance(uuid_dict, dict) |
| 17 | +base_dir = os.path.abspath(os.path.dirname(__file__)) |
| 18 | +data_dir = os.path.join(base_dir, "data") |
31 | 19 |
|
32 | | - indices = list(uuid_dict.values()) |
33 | | - indices.sort() |
34 | | - assert all(indices[i] > indices[i - 1] for i in range(1, len(indices))) |
35 | | - for uuid in uuid_dict.keys(): |
36 | | - assert isinstance(uuid, str) |
37 | 20 |
|
| 21 | +def test_mesh_components(client: FlaskClient) -> None: |
| 22 | + geode_object_type = "BRep" |
| 23 | + filename = "cube.og_brep" |
| 24 | + response = test_save_viewable_file(client, geode_object_type, filename) |
38 | 25 |
|
39 | | -def test_extract_brep_uuids(client: FlaskClient, test_id: str) -> None: |
40 | 26 | route = "/opengeodeweb_back/models/mesh_components" |
41 | 27 | brep_filename = os.path.join(data_dir, "cube.og_brep") |
42 | 28 |
|
43 | | - with client.application.app_context(): |
44 | | - data = Data.create( |
45 | | - geode_object=GeodeBRep.geode_object_type(), |
46 | | - viewer_object=GeodeBRep.viewer_type(), |
47 | | - input_file=brep_filename, |
48 | | - ) |
49 | | - data.native_file = brep_filename |
50 | | - session = get_session() |
51 | | - if session: |
52 | | - session.commit() |
53 | | - |
54 | | - response = client.post(route, json={"id": data.id}) |
55 | | - assert response.status_code == 200 |
56 | | - assert "uuid_dict" in response.get_json() |
57 | | - uuid_dict = response.get_json()["uuid_dict"] |
58 | | - assert isinstance(uuid_dict, dict) |
| 29 | + response = client.post(route, json={"id": response.get_json()["id"]}) |
| 30 | + assert response.status_code == 200 |
| 31 | + assert "mesh_components" in response.get_json() |
| 32 | + mesh_components = response.get_json()["mesh_components"] |
| 33 | + assert isinstance(mesh_components, list) |
| 34 | + assert len(mesh_components) > 0 |
| 35 | + for mesh_component in mesh_components: |
| 36 | + assert isinstance(mesh_component, object) |
| 37 | + assert isinstance(mesh_component["id"], str) |
| 38 | + assert isinstance(mesh_component["geode_id"], str) |
| 39 | + assert isinstance(mesh_component["viewer_id"], int) |
| 40 | + assert isinstance(mesh_component["name"], str) |
| 41 | + assert isinstance(mesh_component["type"], str) |
59 | 42 |
|
60 | 43 |
|
61 | 44 | def test_export_project_route(client: FlaskClient, tmp_path: Path) -> None: |
@@ -178,33 +161,6 @@ def test_import_project_route(client: FlaskClient, tmp_path: Path) -> None: |
178 | 161 | client.application.config["DATA_FOLDER_PATH"] = original_data_folder |
179 | 162 |
|
180 | 163 |
|
181 | | -def test_save_viewable_workflow_from_file(client: FlaskClient) -> None: |
182 | | - file = os.path.join(data_dir, "cube.og_brep") |
183 | | - upload_resp = client.put( |
184 | | - "/opengeodeweb_back/upload_file", |
185 | | - data={"file": FileStorage(open(file, "rb"))}, |
186 | | - ) |
187 | | - assert upload_resp.status_code == 201 |
188 | | - |
189 | | - route = "/opengeodeweb_back/save_viewable_file" |
190 | | - payload = {"geode_object_type": "BRep", "filename": "cube.og_brep"} |
191 | | - |
192 | | - response = client.post(route, json=payload) |
193 | | - assert response.status_code == 200 |
194 | | - |
195 | | - data_id = response.get_json()["id"] |
196 | | - assert isinstance(data_id, str) and len(data_id) > 0 |
197 | | - assert response.get_json()["viewable_file"].endswith(".vtm") |
198 | | - |
199 | | - comp_resp = client.post( |
200 | | - "/opengeodeweb_back/models/vtm_component_indices", json={"id": data_id} |
201 | | - ) |
202 | | - assert comp_resp.status_code == 200 |
203 | | - |
204 | | - refreshed = Data.get(data_id) |
205 | | - assert refreshed is not None |
206 | | - |
207 | | - |
208 | 164 | def test_save_viewable_workflow_from_object(client: FlaskClient) -> None: |
209 | 165 | route = "/opengeodeweb_back/create/point" |
210 | 166 | point_data = { |
|
0 commit comments