From b6bd0f11102c19e24e85a2c16c0c5644ec9261ae Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 10 Dec 2018 15:55:34 +0300 Subject: [PATCH] [Code coverage FeaturesPlugin]: Improve coverage for Boolean operations --- src/FeaturesPlugin/CMakeLists.txt | 6 ++ .../Test/TestBooleanCommon_ErrorMsg.py | 11 ++++ .../Test/TestBooleanCut_Compound_Solid.py | 45 +++++++++++++ .../Test/TestBooleanCut_ErrorMsg.py | 36 ++++++++++ .../Test/TestBooleanFill_ErrorMsg.py | 36 ++++++++++ .../Test/TestBooleanFuse_CompSolid_Face.py | 66 +++++++++++++++++++ .../Test/TestBooleanFuse_ErrorMsg.py | 11 ++++ .../Test/TestBooleanSmash_CompSolid_Solid.py | 44 +++++++++++++ .../Test/TestBooleanSmash_ErrorMsg.py | 11 ++++ .../Test/TestFillCompsolidPlane.py | 48 ++++++++++++++ .../Test/TestMeasurementPresentation.py | 25 +++++-- .../Test/TestPartition_ErrorMsg.py | 11 ++++ 12 files changed, 345 insertions(+), 5 deletions(-) create mode 100644 src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py create mode 100644 src/FeaturesPlugin/Test/TestFillCompsolidPlane.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 9896d68af..538b466a6 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -200,6 +200,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanSmash.py TestBooleanFill.py TestBooleanFillWithPlane.py + TestBooleanFill_ErrorMsg.py TestMultiBoolean.py TestSerialBoolean.py TestBoolean_ErrorMsg.py @@ -257,6 +258,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillSolidCompFace.py TestFillSolidShell.py TestFillSolidCompShell.py + TestFillCompsolidPlane.py TestPartition2Faces.py TestPartition2Solids.py TestPartition2Wires.py @@ -333,8 +335,11 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanCut_Wire_Face.py TestBooleanCut_Wire_Wire.py TestBooleanCut_WireCompound_WireCompound.py + TestBooleanCut_Compound_Solid.py + TestBooleanCut_ErrorMsg.py TestBooleanSmash_Face_Face.py TestBooleanSmash_SubSolid_Solid.py + TestBooleanSmash_CompSolid_Solid.py TestBooleanSmash_ErrorMsg.py TestBooleanFuse_SimpleMode.py TestBooleanFuse_RemoveEdges.py @@ -399,6 +404,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanFuse_ShellCompound_ShellCompound.py TestBooleanFuse_Solid_Solid.py TestBooleanFuse_SolidCompound_SolidCompound.py + TestBooleanFuse_CompSolid_Face.py TestBooleanFuse_CompSolid_CompSolid.py TestBooleanFuse_CompSolidCompound_CompSolidCompound.py TestFillet.py diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py index 06c97a58b..1c1143fbd 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py @@ -35,3 +35,14 @@ assert(Common_1.feature().error() != "") Part_1_doc.removeFeature(Common_1.feature()) model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Common_1 = Part_1_doc.addFeature("Common") +Common_1.execute() +assert(Common_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py new file mode 100644 index 000000000..6e858996a --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py @@ -0,0 +1,45 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OX"), 20) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Translation_1_1")]) +Box_3 = model.addBox(Part_1_doc, 20, 6, 20) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], -5, 2, -5) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1")], [model.selection("SOLID", "Translation_2_1")]) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [3]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [18]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [72]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [144]) +model.testResultsVolumes(Cut_1, [1400]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py new file mode 100644 index 000000000..254980392 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py @@ -0,0 +1,36 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Cut_1 = aPart.addFeature("Cut") +Cut_1.execute() +assert(Cut_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py new file mode 100644 index 000000000..612fdf486 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py @@ -0,0 +1,36 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Fill_1 = aPart.addFeature("Fill") +Fill_1.execute() +assert(Fill_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py new file mode 100644 index 000000000..90d0037bb --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py @@ -0,0 +1,66 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model +from GeomAPI import GeomAPI_Shape + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(52.27216563767099, 0, 18.66006927176168) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center()) +SketchCircle_2 = Sketch_1.addCircle(79.68333887668101, 0, 24.16077154338278) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) +SketchLine_2 = Sketch_2.addLine(73.13136007081269, -14.25937060400964, 2.118687665902372, -14.25937060400964) +SketchLine_3 = Sketch_2.addLine(2.118687665902372, -14.25937060400964, 2.118687665902372, 26.70061277610758) +SketchLine_4 = Sketch_2.addLine(2.118687665902372, 26.70061277610758, 73.13136007081269, 26.70061277610758) +SketchLine_5 = Sketch_2.addLine(73.13136007081269, 26.70061277610758, 73.13136007081269, -14.25937060400964) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_2.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_3.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_4.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_5.result()) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r")]) +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], [model.selection("FACE", "Face_1_1")]) + +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [2]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [4]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [16]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [32]) +model.testResultsVolumes(Fuse_1, [785.398163397447774514148477465]) + +Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Extrusion_1_1_1")], [model.selection("FACE", "Fuse_1_1_1")]) +assert(Fuse_2.feature().error() != "") + +model.end() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py index 17441ab13..1801cab5a 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py @@ -39,3 +39,14 @@ Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1")] assert(Fuse_1.feature().error() != "") Part_1_doc.removeFeature(Fuse_1.feature()) model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Fuse_1 = Part_1_doc.addFeature("Fuse") +Fuse_1.execute() +assert(Fuse_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py new file mode 100644 index 000000000..4819afe11 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py @@ -0,0 +1,44 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-0.820365148699405, 7.40718257641344, 6.028904154999336) +SketchCircle_2 = Sketch_1.addCircle(10.62009910116713, 13.94078752172051, 10.99163472554975) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("SOLID", "Box_1_1")]) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Smash_1, 1) +model.testNbSubResults(Smash_1, [4]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [4]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [28]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [120]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [240]) +model.testResultsVolumes(Smash_1, [4980.404017506245509139262139797]) diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py index b4a0fbcea..519b542e2 100644 --- a/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py @@ -58,3 +58,14 @@ assert(Smash_1.feature().error() != "") Part_1_doc.removeFeature(Smash_1.feature()) model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Smash_1 = Part_1_doc.addFeature("Smash") +Smash_1.execute() +assert(Smash_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestFillCompsolidPlane.py b/src/FeaturesPlugin/Test/TestFillCompsolidPlane.py new file mode 100644 index 000000000..555810909 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestFillCompsolidPlane.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(11.92861402549826, 0, 16.05621803603458) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center()) +SketchCircle_2 = Sketch_1.addCircle(37.8779560884558, 0, 17.74637067763095) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("FACE", "PartSet/XOZ")]) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Fill_1, 1) +model.testNbSubResults(Fill_1, [5]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.SOLID, [5]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.FACE, [25]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.EDGE, [90]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.VERTEX, [180]) +model.testResultsVolumes(Fill_1, [16831.622023411000554915517568588]) diff --git a/src/FeaturesPlugin/Test/TestMeasurementPresentation.py b/src/FeaturesPlugin/Test/TestMeasurementPresentation.py index c64660c8a..97d2f80ef 100644 --- a/src/FeaturesPlugin/Test/TestMeasurementPresentation.py +++ b/src/FeaturesPlugin/Test/TestMeasurementPresentation.py @@ -47,7 +47,10 @@ aSession.startOperation() aMeasurement = Part_1_doc.addFeature("Measurement") aMeasurement.string("MeasureKind").setValue("Length") aMeasurement.selection("edge_for_length").selectSubShape("EDGE", "Sketch_1/SketchLine_1") -assert(featureToPresentation(aMeasurement).getAISObject(None) is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) aSession.finishOperation() aSession.startOperation() @@ -55,14 +58,20 @@ aMeasurement = Part_1_doc.addFeature("Measurement") aMeasurement.string("MeasureKind").setValue("Distance") aMeasurement.selection("distance_from").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex") aMeasurement.selection("distance_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2") -assert(featureToPresentation(aMeasurement).getAISObject(None) is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) aSession.finishOperation() aSession.startOperation() aMeasurement = Part_1_doc.addFeature("Measurement") aMeasurement.string("MeasureKind").setValue("Radius") aMeasurement.selection("circular").selectSubShape("EDGE", "Sketch_1/SketchArc_1_2") -assert(featureToPresentation(aMeasurement).getAISObject(None) is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) aSession.finishOperation() aSession.startOperation() @@ -70,7 +79,10 @@ aMeasurement = Part_1_doc.addFeature("Measurement") aMeasurement.string("MeasureKind").setValue("Angle") aMeasurement.selection("angle_from").selectSubShape("EDGE", "Sketch_1/SketchLine_1") aMeasurement.selection("angle_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2") -assert(featureToPresentation(aMeasurement).getAISObject(None) is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) aSession.finishOperation() aSession.startOperation() @@ -79,5 +91,8 @@ aMeasurement.string("MeasureKind").setValue("AngleBy3Points") aMeasurement.selection("angle_point_1").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex") aMeasurement.selection("angle_point_2").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_EndVertex") aMeasurement.selection("angle_point_3").selectSubShape("VERTEX", "Sketch_1/SketchLine_2_EndVertex") -assert(featureToPresentation(aMeasurement).getAISObject(None) is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py b/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py index 40782a434..9addcbe6a 100644 --- a/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py +++ b/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py @@ -45,3 +45,14 @@ assert(Partition_1.feature().error() != "") Part_1_doc.removeFeature(Partition_1.feature()) model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Partition_1 = Part_1_doc.addFeature("Partition") +Partition_1.execute() +assert(Partition_1.error() != "") +aSession.finishOperation() -- 2.30.2