|
1 | | -import shutil |
2 | 1 | import os |
| 2 | +import shutil |
3 | 3 |
|
4 | | - |
5 | | -def test_model_mesh_components(client, uuid_project_structure): |
| 4 | +def test_model_mesh_components(client): |
| 5 | + test_id = "1" |
6 | 6 | route = "/models/vtm_component_indices" |
7 | | - uuid_data = uuid_project_structure["uuid_data"] |
8 | | - data_path = uuid_project_structure["data_path"] |
9 | 7 |
|
10 | | - shutil.copy("./tests/data/cube.vtm", os.path.join(data_path, "viewable.vtm")) |
| 8 | + base_path = client.application.config["DATA_FOLDER_PATH"] |
| 9 | + data_path = os.path.join(base_path, test_id) |
| 10 | + os.makedirs(data_path, exist_ok=True) |
| 11 | + shutil.copy( |
| 12 | + "./tests/data/cube.vtm", |
| 13 | + os.path.join(data_path, "viewable.vtm") |
| 14 | + ) |
11 | 15 |
|
12 | | - original_path = client.application.config["DATA_FOLDER_PATH"] |
13 | | - client.application.config["DATA_FOLDER_PATH"] = uuid_project_structure["base_path"] |
| 16 | + response = client.post(route, json={"id": test_id}) |
| 17 | + assert response.status_code == 200 |
14 | 18 |
|
15 | | - try: |
16 | | - response = client.post(route, json={"id": uuid_data}) |
17 | | - assert response.status_code == 200 |
18 | | - uuid_dict = response.json["uuid_to_flat_index"] |
19 | | - assert isinstance(uuid_dict, dict) |
| 19 | + uuid_dict = response.json["uuid_to_flat_index"] |
| 20 | + assert isinstance(uuid_dict, dict) |
20 | 21 |
|
21 | | - indices = list(uuid_dict.values()) |
22 | | - indices.sort() |
23 | | - assert all(indices[i] > indices[i - 1] for i in range(1, len(indices))) |
24 | | - for uuid_key in uuid_dict.keys(): |
25 | | - assert isinstance(uuid_key, str) |
26 | | - finally: |
27 | | - client.application.config["DATA_FOLDER_PATH"] = original_path |
| 22 | + indices = sorted(uuid_dict.values()) |
| 23 | + assert all(indices[i] > indices[i-1] for i in range(1, len(indices))) |
| 24 | + for key in uuid_dict: |
| 25 | + assert isinstance(key, str) |
28 | 26 |
|
29 | 27 |
|
30 | | -def test_extract_brep_uuids(client, uuid_project_structure): |
| 28 | +def test_extract_brep_uuids(client): |
| 29 | + test_id = "1" |
31 | 30 | route = "/models/mesh_components" |
32 | | - uuid_data = uuid_project_structure["uuid_data"] |
33 | | - data_path = uuid_project_structure["data_path"] |
34 | | - |
35 | | - shutil.copy("./tests/data/cube.og_brep", os.path.join(data_path, "cube.og_brep")) |
36 | | - |
37 | | - original_path = client.application.config["DATA_FOLDER_PATH"] |
38 | | - client.application.config["DATA_FOLDER_PATH"] = uuid_project_structure["base_path"] |
39 | | - |
40 | | - try: |
41 | | - json_data = { |
42 | | - "filename": "cube.og_brep", |
43 | | - "geode_object": "BRep", |
44 | | - "id": uuid_data, |
45 | | - } |
46 | | - response = client.post(route, json=json_data) |
47 | | - assert response.status_code == 200 |
48 | | - |
49 | | - uuid_dict = response.json["uuid_dict"] |
50 | | - assert isinstance(uuid_dict, dict) |
51 | | - expected_keys = {"Block", "Line", "Surface", "Corner"} |
52 | | - assert any(key in uuid_dict for key in expected_keys) |
53 | | - for key, value in uuid_dict.items(): |
54 | | - assert isinstance(value, list) |
55 | | - assert all(isinstance(v, str) for v in value) |
56 | | - finally: |
57 | | - client.application.config["DATA_FOLDER_PATH"] = original_path |
| 31 | + |
| 32 | + base_path = client.application.config["DATA_FOLDER_PATH"] |
| 33 | + data_path = os.path.join(base_path, test_id) |
| 34 | + os.makedirs(data_path, exist_ok=True) |
| 35 | + shutil.copy( |
| 36 | + "./tests/data/cube.og_brep", |
| 37 | + os.path.join(data_path, "cube.og_brep") |
| 38 | + ) |
| 39 | + |
| 40 | + json_data = { |
| 41 | + "id": test_id, |
| 42 | + "geode_object": "BRep", |
| 43 | + "filename": "cube.og_brep" |
| 44 | + } |
| 45 | + response = client.post(route, json=json_data) |
| 46 | + assert response.status_code == 200 |
| 47 | + |
| 48 | + uuid_dict = response.json["uuid_dict"] |
| 49 | + assert isinstance(uuid_dict, dict) |
| 50 | + expected = {"Block", "Line", "Surface", "Corner"} |
| 51 | + assert any(k in uuid_dict for k in expected) |
| 52 | + for values in uuid_dict.values(): |
| 53 | + assert isinstance(values, list) |
| 54 | + assert all(isinstance(v, str) for v in values) |
| 55 | + |
0 commit comments