From: Clarisse Genrault Date: Mon, 2 Oct 2017 13:52:09 +0000 (+0200) Subject: Adding torus tests for parametric API. X-Git-Tag: V_2.9.0~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a216b9beb07e49627d2b289472011a87ff3ee945;p=modules%2Fshaper.git Adding torus tests for parametric API. --- diff --git a/test.API/SHAPER/CMakeLists.txt b/test.API/SHAPER/CMakeLists.txt index 46dad6a53..f29553032 100644 --- a/test.API/SHAPER/CMakeLists.txt +++ b/test.API/SHAPER/CMakeLists.txt @@ -25,6 +25,7 @@ ADD_UNIT_TESTS_API( Primitives/TestCone.py Primitives/TestCylinder.py Primitives/TestSphere.py + Primitives/TestTorus.py Primitives/TestAPI_Box.py Primitives/TestAPI_Cylinder.py GDML/TestConeSegment.py diff --git a/test.API/SHAPER/Primitives/TestTorus.py b/test.API/SHAPER/Primitives/TestTorus.py new file mode 100644 index 000000000..a60d9daf3 --- /dev/null +++ b/test.API/SHAPER/Primitives/TestTorus.py @@ -0,0 +1,80 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Init +Point_1 = model.addPoint(Part_1_doc, 10, 10, 10).result() +Point_2 = model.selection("VERTEX", "pnt") +Axis_1 = model.addAxis(Part_1_doc, 0, 10, 0).result() +Axis_2 = model.selection("EDGE", "edge") + +# Parameters +model.addParameter(Part_1_doc, "r", "10") +model.addParameter(Part_1_doc, "ring", "3") + +# Tests +Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 3) +Torus_2 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Torus_3 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 0, 3) +Torus_4 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), -10, 3) +Torus_5 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 0) +Torus_6 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, -3) +Torus_7 = model.addTorus(Part_1_doc, Point_1, model.selection("EDGE", "PartSet/OX"), 12, 7) +Torus_8 = model.addTorus(Part_1_doc, Point_1, Axis_1, 15, 4) +Torus_9 = model.addTorus(Part_1_doc, Point_2, model.selection("EDGE", "PartSet/OZ"), 15, 4) +Torus_10 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), Axis_2, 15, 4) +Torus_11 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r", "ring") + +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Torus_1, 1) +model.testNbSubResults(Torus_1, [0]) +model.testNbSubShapes(Torus_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Torus_1, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Torus_1, model, Part_1_doc) + +model.testNbResults(Torus_7, 1) +model.testNbSubResults(Torus_7, [0]) +model.testNbSubShapes(Torus_7, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Torus_7, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Torus_7, model, Part_1_doc) + +model.testNbResults(Torus_8, 1) +model.testNbSubResults(Torus_8, [0]) +model.testNbSubShapes(Torus_8, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Torus_8, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Torus_8, model, Part_1_doc) + +model.testNbResults(Torus_11, 1) +model.testNbSubResults(Torus_11, [0]) +model.testNbSubShapes(Torus_11, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Torus_11, GeomAPI_Shape.FACE, [1]) +model.testHaveNamingFaces(Torus_11, model, Part_1_doc) + +model.testNbResults(Torus_2, 0) +assert(Torus_2.feature().error() == "Torus builder :: ring radius is greater than the radius.") + +model.testNbResults(Torus_3, 0) +assert(Torus_3.feature().error() == "Torus builder :: radius is negative or null.") + +model.testNbResults(Torus_4, 0) +assert(Torus_4.feature().error() == "Torus builder :: radius is negative or null.") + +model.testNbResults(Torus_5, 0) +assert(Torus_5.feature().error() == "Torus builder :: ring radius is negative or null.") + +model.testNbResults(Torus_6, 0) +assert(Torus_6.feature().error() == "Torus builder :: ring radius is negative or null.") + +model.testNbResults(Torus_9, 0) +assert(Torus_9.feature().error() == "Attribute \"base_point\" is not initialized.") + +model.testNbResults(Torus_10, 0) +assert(Torus_10.feature().error() == "Attribute \"axis\" is not initialized.")