]> SALOME platform Git repositories - modules/shaper.git/blob - test.API/SHAPER/Primitives/TestSphere.py
Salome HOME
[Code coverage PrimitivesAPI]: Improve coverage
[modules/shaper.git] / test.API / SHAPER / Primitives / TestSphere.py
1 from salome.shaper import model
2
3 model.begin()
4 partSet = model.moduleDocument()
5 Part_1 = model.addPart(partSet)
6 Part_1_doc = Part_1.document()
7
8 # Init
9 Point_1 = model.addPoint(Part_1_doc, 10, 10, 10).result()
10 Point_2 = model.selection("VERTEX", "pnt")
11
12 # Parameters
13 model.addParameter(Part_1_doc, "r", "5")
14
15 # Tests
16 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
17 Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 0)
18 Sphere_3 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), -5)
19 Sphere_4 = model.addSphere(Part_1_doc, Point_1, 10)
20 Sphere_5 = model.addSphere(Part_1_doc, Point_2, 10)
21 Sphere_6 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r")
22
23 Sphere_7 = model.addSphere(Part_1_doc, 10)
24 Sphere_7.setCenterPoint(Point_1)
25
26 model.do()
27 model.end()
28
29 # Checks
30 from GeomAPI import GeomAPI_Shape
31
32 model.testNbResults(Sphere_1, 1)
33 model.testNbSubResults(Sphere_1, [0])
34 model.testNbSubShapes(Sphere_1, GeomAPI_Shape.SOLID, [1])
35 model.testNbSubShapes(Sphere_1, GeomAPI_Shape.FACE, [1])
36 model.testHaveNamingFaces(Sphere_1, model, Part_1_doc)
37
38 model.testNbResults(Sphere_4, 1)
39 model.testNbSubResults(Sphere_4, [0])
40 model.testNbSubShapes(Sphere_4, GeomAPI_Shape.SOLID, [1])
41 model.testNbSubShapes(Sphere_4, GeomAPI_Shape.FACE, [1])
42 model.testHaveNamingFaces(Sphere_4, model, Part_1_doc)
43
44 model.testNbResults(Sphere_6, 1)
45 model.testNbSubResults(Sphere_6, [0])
46 model.testNbSubShapes(Sphere_6, GeomAPI_Shape.SOLID, [1])
47 model.testNbSubShapes(Sphere_6, GeomAPI_Shape.FACE, [1])
48 model.testHaveNamingFaces(Sphere_6, model, Part_1_doc)
49
50 model.testNbResults(Sphere_7, 1)
51 model.testNbSubResults(Sphere_7, [0])
52 model.testNbSubShapes(Sphere_7, GeomAPI_Shape.SOLID, [1])
53 model.testNbSubShapes(Sphere_7, GeomAPI_Shape.FACE, [1])
54 model.testHaveNamingFaces(Sphere_7, model, Part_1_doc)
55
56 model.testNbResults(Sphere_2, 0)
57 assert(Sphere_2.feature().error() == "Sphere builder :: radius is negative or null.")
58
59 model.testNbResults(Sphere_3, 0)
60 assert(Sphere_3.feature().error() == "Sphere builder :: radius is negative or null.")
61
62 model.testNbResults(Sphere_5, 0)
63 assert(Sphere_5.feature().error() == "Attribute \"center_point\" is not initialized.")