From: nds Date: Wed, 26 Apr 2017 11:17:58 +0000 (+0300) Subject: Unit test for filter horizontal and vertical segments in H and V constraints X-Git-Tag: V_2.7.1.1~3^2~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3cac101c511f53a9a420cd1c9ccb7e910377415;p=modules%2Fshaper.git Unit test for filter horizontal and vertical segments in H and V constraints --- diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 1d18e369d..3f8723de7 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -142,6 +142,7 @@ ADD_UNIT_TESTS(TestSketchPointLine.py TestConstraintRadius.py TestConstraintFixed.py TestConstraintHorizontal.py + TestConstraintHorizontalValidator.py TestConstraintVertical.py TestConstraintEqual.py TestConstraintTangent.py diff --git a/src/SketchPlugin/Test/TestConstraintHorizontalValidator.py b/src/SketchPlugin/Test/TestConstraintHorizontalValidator.py new file mode 100644 index 000000000..ff225fbc4 --- /dev/null +++ b/src/SketchPlugin/Test/TestConstraintHorizontalValidator.py @@ -0,0 +1,57 @@ +""" + TestConstraintHorizontalValidator.py + It tests validation of horizontal and vertical segments in H and V constraints to avoid + selection segments that already have one of these constraint" +""" + +#========================================================================= +# of the test +#========================================================================= +from salome.shaper import model +from ModelAPI import * +import math +#========================================================================= +# Creation of a part +#========================================================================= +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +#========================================================================= +# Creation of a sketch +#========================================================================= +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(20, 20, 40, 80) +SketchLine_1.setName("SketchLine_1") +SketchLine_1.result().setName("SketchLine_1") +SketchLine_2 = Sketch_1.addLine(40, 80, 60, 40) +SketchLine_2.setName("SketchLine_2") +SketchLine_2.result().setName("SketchLine_2") +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2") +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) +SketchConstraintHorizontal_1.setName("SketchConstraintHorizontal_1") +SketchConstraintVertical_1.setName("SketchConstraintVertical_1") +model.do() +#========================================================================= +# Checking that sketch and constraints become invalid when to one line +# two horizontal/vertical constraints are applied in any combination +#========================================================================= +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Sketch_1.feature())) +assert(Sketch_1.feature().error() == "Sketch objects are not defined") +#========================================================================= +# Remove duplicated Vertical constraints +#========================================================================= +Part_1_doc.removeFeature(SketchConstraintVertical_1.feature()) +assert(aFactory.validate(Sketch_1.feature())) +model.do() +#========================================================================= +# Checking that after excess constraints are removed or undone, +# sketch becomes valid. +#========================================================================= +assert(aFactory.validate(Sketch_1.feature())) +assert(Sketch_1.feature().error() == '') + +#assert(model.checkPythonDump())