1- # import pytest
2- import os
3- import compas
41import json
2+ import os
3+
54import pytest
65
6+ import compas
77from compas .datastructures import Mesh
88from compas .datastructures import meshes_join_and_weld
9+ from compas .geometry import Box
910from compas .geometry import Polygon
1011from 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
2431def 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