Skip to content

Commit bb371dd

Browse files
authored
Merge pull request #143 from Geode-solutions/fix_blueprint_models
fix(blueprint_models): Change getroot to find & rm current_index from…
2 parents 397ad70 + 3ddcf96 commit bb371dd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/opengeodeweb_back/routes/models/blueprint_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ def uuid_to_flat_index():
2525
)
2626

2727
tree = ET.parse(vtm_file_path)
28-
root = tree.getroot()
28+
root = tree.find("vtkMultiBlockDataSet")
2929
uuid_to_flat_index = {}
3030
current_index = 1
3131

3232
for elem in root.iter():
3333
if "uuid" in elem.attrib and elem.tag == "DataSet":
3434
uuid_to_flat_index[elem.attrib["uuid"]] = current_index
35-
current_index += 1
35+
current_index += 1
3636

3737
return flask.make_response(
3838
{"uuid_to_flat_index": uuid_to_flat_index},

tests/test_models_routes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ def test_model_mesh_components(client):
44
json = get_full_data()
55
response = client.post(route, json=json)
66
assert response.status_code == 200
7+
78
uuid_dict = response.json["uuid_to_flat_index"]
8-
assert type(uuid_dict) is dict
9+
assert isinstance(uuid_dict, dict)
910

1011
indices = list(uuid_dict.values())
1112
indices.sort()
12-
assert indices[0] == 1
13-
assert all(indices[i] == indices[i - 1] + 1 for i in range(1, len(indices)))
13+
assert all(indices[i] > indices[i - 1] for i in range(1, len(indices)))
14+
for uuid in uuid_dict.keys():
15+
assert isinstance(uuid, str)
1416

1517

1618
def test_extract_brep_uuids(client):
1719
route = "/models/mesh_components"
1820
json_data = {"filename": "cube.og_brep", "geode_object": "BRep"}
19-
2021
response = client.post(route, json=json_data)
2122

2223
assert response.status_code == 200
2324
uuid_dict = response.json["uuid_dict"]
2425
assert isinstance(uuid_dict, dict)
25-
assert (
26-
"Block" in uuid_dict
27-
or "Line" in uuid_dict
28-
or "Surface" in uuid_dict
29-
or "Corner" in uuid_dict
30-
)
26+
expected_keys = {"Block", "Line", "Surface", "Corner"}
27+
assert any(key in uuid_dict for key in expected_keys)
28+
for key, value in uuid_dict.items():
29+
assert isinstance(value, list)
30+
assert all(isinstance(v, str) for v in value)

0 commit comments

Comments
 (0)