Skip to content

Commit 7a946b1

Browse files
committed
halfface default attributes tests
1 parent 6060e22 commit 7a946b1

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from compas.datastructures import HalfFace
2+
3+
4+
# ==============================================================================
5+
# Fixtures
6+
# ==============================================================================
7+
8+
# ==============================================================================
9+
# Tests - Schema & jsonschema
10+
# ==============================================================================
11+
12+
# ==============================================================================
13+
# Tests - Vertex Attributes
14+
# ==============================================================================
15+
16+
17+
def test_default_vertex_attributes():
18+
he = HalfFace(name='test', default_vertex_attributes={'a': 1, 'b': 2})
19+
for vertex in he.vertices():
20+
assert he.vertex_attribute(vertex, name='a') == 1
21+
assert he.vertex_attribute(vertex, name='b') == 2
22+
he.vertex_attribute(vertex, name='a', value=3)
23+
assert he.vertex_attribute(vertex, name='a') == 3
24+
25+
26+
# ==============================================================================
27+
# Tests - Face Attributes
28+
# ==============================================================================
29+
30+
31+
def test_default_face_attributes():
32+
he = HalfFace(name='test', default_face_attributes={'a': 1, 'b': 2})
33+
for face in he.vertices():
34+
assert he.face_attribute(face, name='a') == 1
35+
assert he.face_attribute(face, name='b') == 2
36+
he.face_attribute(face, name='a', value=3)
37+
assert he.face_attribute(face, name='a') == 3
38+
39+
40+
# ==============================================================================
41+
# Tests - Edge Attributes
42+
# ==============================================================================
43+
44+
45+
def test_default_edge_attributes():
46+
he = HalfFace(name='test', default_edge_attributes={'a': 1, 'b': 2})
47+
for edge in he.vertices():
48+
assert he.edge_attribute(edge, name='a') == 1
49+
assert he.edge_attribute(edge, name='b') == 2
50+
he.edge_attribute(edge, name='a', value=3)
51+
assert he.edge_attribute(edge, name='a') == 3
52+
53+
54+
# ==============================================================================
55+
# Tests - Cell Attributes
56+
# ==============================================================================
57+
58+
59+
def test_default_cell_attributes():
60+
he = HalfFace(name='test', default_cell_attributes={'a': 1, 'b': 2})
61+
for cell in he.vertices():
62+
assert he.cell_attribute(cell, name='a') == 1
63+
assert he.cell_attribute(cell, name='b') == 2
64+
he.cell_attribute(cell, name='a', value=3)
65+
assert he.cell_attribute(cell, name='a') == 3

0 commit comments

Comments
 (0)