Skip to content

Commit 122701f

Browse files
committed
Updated unittest after inheritance fix
1 parent d880545 commit 122701f

1 file changed

Lines changed: 58 additions & 6 deletions

File tree

test/occutils_test.py

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,26 @@
2222

2323
sys.path.append('../OCCUtils')
2424

25-
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
25+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakeSphere
2626
from OCC.TopoDS import TopoDS_Face, TopoDS_Edge
2727

2828
from Topology import Topo
2929
from edge import Edge
30+
from face import Face
31+
from wire import Wire
32+
from vertex import Vertex
33+
from shell import Shell
34+
from solid import Solid
3035

3136

3237
def get_test_box_shape():
3338
return BRepPrimAPI_MakeBox(10, 20, 30).Shape()
3439

3540

41+
def get_test_sphere_shape():
42+
return BRepPrimAPI_MakeSphere(10.).Shape()
43+
44+
3645
class TestTopo(unittest.TestCase):
3746
def test_init(self):
3847
b = get_test_box_shape()
@@ -79,15 +88,58 @@ def test_creat_edge(self):
7988
edge_0 = t.edges().next() # it's a TopoDS_Edge
8089
assert not edge_0.IsNull()
8190
# then create an edge
82-
my_Edge = Edge(edge_0)
83-
assert not my_Edge.IsNull()
84-
assert my_Edge.tolerance == 1e-06
91+
my_edge = Edge(edge_0)
92+
assert not my_edge.IsNull()
93+
assert my_edge.tolerance == 1e-06
94+
assert my_edge.type == 'line'
95+
assert my_edge.length() == 30.
96+
97+
98+
class TestFace(unittest.TestCase):
99+
def test_creat_face(self):
100+
# create a box
101+
my_face = Face(BRepPrimAPI_MakeSphere(1., 1.).Face())
102+
assert not my_face.IsNull()
103+
assert my_face.tolerance == 1e-06
104+
assert not my_face.is_planar()
105+
assert my_face.is_trimmed()
106+
107+
108+
class TestWire(unittest.TestCase):
109+
def test_creat_face(self):
110+
# create a box
111+
b = get_test_box_shape()
112+
# take the first edge
113+
t = Topo(b)
114+
wire = t.wires().next()
115+
my_wire = Wire(wire)
116+
assert not my_wire.IsNull()
117+
assert my_wire.tolerance == 1e-06
118+
119+
120+
class TestVertex(unittest.TestCase):
121+
def test_creat_vertex(self):
122+
my_vertex = Vertex(1., 2., -2.6)
123+
assert my_vertex.tolerance == 1e-06
124+
assert my_vertex.x == 1.
125+
assert my_vertex.y == 2.
126+
assert my_vertex.z == -2.6
127+
128+
129+
class TestShell(unittest.TestCase):
130+
def test_creat_shell(self):
131+
my_shell = Shell(BRepPrimAPI_MakeBox(10, 20, 30).Shell())
132+
assert my_shell.tolerance == 1e-06
133+
134+
135+
class TestSolid(unittest.TestCase):
136+
def test_creat_solid(self):
137+
my_solid = Solid(BRepPrimAPI_MakeBox(10, 20, 30).Solid())
138+
assert my_solid.tolerance == 1e-06
85139

86140

87141
def suite():
88142
test_suite = unittest.TestSuite()
89-
test_suite.addTest(unittest.makeSuite(TestTopo))
90-
test_suite.addTest(unittest.makeSuite(TestEdge))
91143
return test_suite
92144

93145
if __name__ == "__main__":

0 commit comments

Comments
 (0)