Salome HOME
[Code coverage BuildPlugin]: Unit tests to check error messages
authorazv <azv@opencascade.com>
Fri, 7 Dec 2018 09:11:28 +0000 (12:11 +0300)
committerazv <azv@opencascade.com>
Fri, 7 Dec 2018 09:11:28 +0000 (12:11 +0300)
src/BuildPlugin/Test/TestCompound_ErrorMsg.py [new file with mode: 0644]
src/BuildPlugin/Test/TestEdge_ErrorMsg.py [new file with mode: 0644]
src/BuildPlugin/Test/TestFilling_ErrorMsg.py [new file with mode: 0644]
src/BuildPlugin/Test/TestSubShapes_ErrorMsg.py [new file with mode: 0644]
src/BuildPlugin/Test/TestVertex_ErrorMsg.py [new file with mode: 0644]
src/BuildPlugin/Test/TestWire_ErrorMsg.py [new file with mode: 0644]
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp

diff --git a/src/BuildPlugin/Test/TestCompound_ErrorMsg.py b/src/BuildPlugin/Test/TestCompound_ErrorMsg.py
new file mode 100644 (file)
index 0000000..c821271
--- /dev/null
@@ -0,0 +1,43 @@
+## Copyright (C) 2017-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<mailto: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()
+Compound_1 = aPart.addFeature("Compound")
+Compound_1.execute()
+assert(Compound_1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aBaseObjectsList = Compound_1.selectionList("base_objects")
+aBaseObjectsList.append("", "EDGE")
+Compound_1.execute()
+assert(Compound_1.error() != "")
+aSession.finishOperation()
diff --git a/src/BuildPlugin/Test/TestEdge_ErrorMsg.py b/src/BuildPlugin/Test/TestEdge_ErrorMsg.py
new file mode 100644 (file)
index 0000000..84476cd
--- /dev/null
@@ -0,0 +1,61 @@
+## Copyright (C) 2017-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<mailto: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()
+
+# Create auxiliary box
+aSession.startOperation()
+aBox = aPart.addFeature("Box")
+aBox.string("CreationMethod").setValue("BoxByDimensions")
+aBox.real("dx").setValue(50)
+aBox.real("dy").setValue(50)
+aBox.real("dz").setValue(50)
+aSession.finishOperation()
+aBoxResult = aBox.firstResult()
+aBoxShape = aBoxResult.shape()
+
+aSession.startOperation()
+Edge_1 = aPart.addFeature("Edge")
+Edge_1.execute()
+assert(Edge_1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aBaseObjectsList = Edge_1.selectionList("base_objects")
+aBaseObjectsList.append("", "EDGE")
+Edge_1.execute()
+assert(Edge_1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aBaseObjectsList.removeLast()
+aBaseObjectsList.append("Box_1_1/Top", "FACE")
+Edge_1.execute()
+assert(Edge_1.error() != "")
+aSession.finishOperation()
diff --git a/src/BuildPlugin/Test/TestFilling_ErrorMsg.py b/src/BuildPlugin/Test/TestFilling_ErrorMsg.py
new file mode 100644 (file)
index 0000000..8ec5a72
--- /dev/null
@@ -0,0 +1,62 @@
+## Copyright (C) 2017-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<mailto: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()
+Point_2 = model.addPoint(Part_1_doc, 10, 0, 0)
+Point_3 = model.addPoint(Part_1_doc, 20, 10, 0)
+Point_4 = model.addPoint(Part_1_doc, 0, 20, 10)
+Point_5 = model.addPoint(Part_1_doc, 30, 0, 10)
+Polyline_1 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], False)
+Polyline_2 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_4")], False)
+model.do()
+
+Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1"), model.selection("EDGE", "Polyline_2_1/Generated_Edge&Point_3/Point_3")], "curve_info", 9, 8, 0, 0.0001, 0.0001, True)
+assert(Filling_1.feature().error() != "")
+Part_1_doc.removeFeature(Filling_1.feature())
+
+Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1")])
+assert(Filling_1.feature().error() != "")
+Part_1_doc.removeFeature(Filling_1.feature())
+
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+
+Filling_1 = model.addFilling(Part_1_doc, [model.selection("FACE", "Box_1_1/Top")])
+assert(Filling_1.feature().error() != "")
+Part_1_doc.removeFeature(Filling_1.feature())
+
+model.end()
+
+from ModelAPI import *
+aSession = ModelAPI_Session.get()
+
+aSession.startOperation()
+aFillingFeature = featureToCompositeFeature(Part_1.feature()).addFeature("Filling")
+aFillingFeature.string("advanced_options").setValue("")
+aBaseObjectsList = aFillingFeature.selectionList("base_objects")
+aBaseObjectsList.append("Polyline_1_1/Generated_Edge&Point_1/Point_1", "EDGE")
+aBaseObjectsList.append("Box_1_1/Top", "FACE")
+aFillingFeature.execute()
+assert(aFillingFeature.error() != "")
+aSession.finishOperation()
diff --git a/src/BuildPlugin/Test/TestSubShapes_ErrorMsg.py b/src/BuildPlugin/Test/TestSubShapes_ErrorMsg.py
new file mode 100644 (file)
index 0000000..9edac3a
--- /dev/null
@@ -0,0 +1,44 @@
+## Copyright (C) 2017-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<mailto: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)
+Polyline_1_objects = [model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]")]
+Polyline_1 = model.addPolyline3D(Part_1_doc, Polyline_1_objects, False)
+model.do()
+
+SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("WIRE", "Polyline_1_1"), [model.selection("EDGE", "Polyline_1_1/Generated_Edge&weak_name_4")])
+assert(SubShapes_1.feature().error() == "")
+
+model.end()
+
+from ModelAPI import *
+aSession = ModelAPI_Session.get()
+
+aSession.startOperation()
+SubShapes_2 = featureToCompositeFeature(Part_1.feature()).addFeature("SubShapes")
+SubShapes_2.execute()
+assert(SubShapes_2.error() == "")
+aSession.finishOperation()
diff --git a/src/BuildPlugin/Test/TestVertex_ErrorMsg.py b/src/BuildPlugin/Test/TestVertex_ErrorMsg.py
new file mode 100644 (file)
index 0000000..0acbeba
--- /dev/null
@@ -0,0 +1,43 @@
+## Copyright (C) 2017-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<mailto: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()
+Vertex_1 = aPart.addFeature("Vertex")
+Vertex_1.execute()
+assert(Vertex_1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aBaseObjectsList = Vertex_1.selectionList("base_objects")
+aBaseObjectsList.append("", "EDGE")
+Vertex_1.execute()
+assert(Vertex_1.error() != "")
+aSession.finishOperation()
diff --git a/src/BuildPlugin/Test/TestWire_ErrorMsg.py b/src/BuildPlugin/Test/TestWire_ErrorMsg.py
new file mode 100644 (file)
index 0000000..d09d5da
--- /dev/null
@@ -0,0 +1,88 @@
+## Copyright (C) 2017-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<mailto: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()
+
+# Create auxiliary box
+aSession.startOperation()
+aBox = aPart.addFeature("Box")
+aBox.string("CreationMethod").setValue("BoxByDimensions")
+aBox.real("dx").setValue(50)
+aBox.real("dy").setValue(50)
+aBox.real("dz").setValue(50)
+aSession.finishOperation()
+aBoxResult = aBox.firstResult()
+aBoxShape = aBoxResult.shape()
+
+aSession.startOperation()
+Wire_1 = aPart.addFeature("Wire")
+Wire_1.execute()
+assert(Wire_1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aBaseObjectsList = Wire_1.selectionList("base_objects")
+aBaseObjectsList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Right][Box_1_1/Top]", "EDGE")
+Wire_1.execute()
+assert(Wire_1.error() != "")
+aSession.finishOperation()
+
+
+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)
+
+Wire_1 = model.addWire(Part_1_doc, [])
+Wire_1.addContour()
+Part_1_doc.removeFeature(Wire_1.feature())
+
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")])
+Wire_1.addContour()
+Part_1_doc.removeFeature(Wire_1.feature())
+
+Wire_1 = model.addWire(Part_1_doc, [model.selection("FACE", "Box_1_1/Top")])
+Wire_1.addContour()
+Part_1_doc.removeFeature(Wire_1.feature())
+
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(26.2037104714363, 14.67693246486999, 44.63854591961698, 30.23007341140914)
+SketchLine_2 = Sketch_1.addLine(44.63854591961698, 30.23007341140914, 20.93564110678636, 53.45762191102688)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+model.do()
+
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")])
+Wire_1.addContour()
+Part_1_doc.removeFeature(Wire_1.feature())
+
+model.end()
index cc299083317be073bda56b3ab5da4bda2d24feca..cd5328a3432b966f7e527e7d86af14264044d92a 100644 (file)
@@ -48,7 +48,7 @@
 //------------------------------------------------------------------------------
 // Tools
 
-std::string toStdString(double theValue)
+static std::string toStdString(double theValue)
 {
   std::ostringstream sstream;
   sstream << theValue;
@@ -59,7 +59,7 @@ std::string toStdString(double theValue)
   return sstream.str() + aPnt;
 }
 
-std::set<std::string> toSet(const std::list<std::string>& theContainer)
+static std::set<std::string> toSet(const std::list<std::string>& theContainer)
 {
   return std::set<std::string>(theContainer.begin(), theContainer.end());
 }