Skip to content

Commit 4075b74

Browse files
committed
Add unit test
1 parent 2c3696d commit 4075b74

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tests/compas/datastructures/test_mesh.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# import pytest
2-
import os
3-
import compas
41
import json
2+
import os
3+
54
import pytest
65

6+
import compas
77
from compas.datastructures import Mesh
88
from compas.datastructures import meshes_join_and_weld
9+
from compas.geometry import Box
910
from compas.geometry import Polygon
1011
from compas.geometry import Translation
1112

@@ -20,6 +21,12 @@ def cube():
2021
return Mesh.from_polyhedron(6)
2122

2223

24+
@pytest.fixture
25+
def box():
26+
box = Box.from_width_height_depth(2, 2, 2)
27+
return Mesh.from_shape(box)
28+
29+
2330
@pytest.fixture
2431
def hexagon():
2532
polygon = Polygon.from_sides_and_radius_xy(6, 1)
@@ -666,3 +673,14 @@ def test_faces_on_boundaries_triangleboundarychain(triangleboundarychain):
666673
# --------------------------------------------------------------------------
667674
# attributes
668675
# --------------------------------------------------------------------------
676+
677+
def test_face_attributes_includes_all_defaults(box):
678+
box.update_default_face_attributes({"attr1": "value1", "attr2": "value2"})
679+
680+
random_fkey = box.get_any_face()
681+
assert sorted(box.face_attributes(random_fkey).keys()) == ['attr1', 'attr2']
682+
683+
box.face_attribute(random_fkey, "attr3", "value3")
684+
assert sorted(box.face_attributes(random_fkey).keys()) == ['attr1', 'attr2', 'attr3']
685+
686+
assert box.face_attribute(random_fkey, "attr3") == 'value3'

0 commit comments

Comments
 (0)