Salome HOME
Update copyrights
[modules/shaper.git] / src / ModelAPI / Test / TestUndoRedo.py
index 3981f30d4f257df0c4604ce52f1cdb38ceefd727..9e3216c945728ffb40623101774ff09d64232a04 100644 (file)
@@ -1,37 +1,54 @@
-from ModelAPI import *\r
-aSession = ModelAPI_Session.get()\r
-aDoc = aSession.moduleDocument()\r
-assert(not aSession.canUndo())\r
-assert(not aSession.canRedo())\r
-\r
-aSession.startOperation()\r
-aFeature = aDoc.addFeature("Point")\r
-# Since validators are introduced we have to initialize all\r
-# the feature's attributes\r
-# aFeature.string("creation_method").setValue("by_xyz")\r
-aFeature.real("x").setValue(1.)\r
-aFeature.real("y").setValue(-1.)\r
-aFeature.real("z").setValue(0.)\r
-aFeatureName = aFeature.name()\r
-# "2" is because Origin is the first point\r
-assert(aFeatureName == "Point_2")\r
-\r
-aFeature.execute()\r
-aSession.finishOperation()\r
-\r
-assert(aDoc.size("Construction") == 8)\r
-assert(aSession.canUndo())\r
-assert(not aSession.canRedo())\r
-\r
-aSession.undo()\r
-assert(aDoc.size("Construction") == 7)\r
-assert(not aSession.canUndo())\r
-assert(aSession.canRedo())\r
-\r
-aSession.redo()\r
-assert(aDoc.size("Construction") == 8)\r
-assert(aSession.canUndo())\r
-assert(not aSession.canRedo())\r
-\r
-import model\r
-assert(model.checkPythonDump())\r
+# Copyright (C) 2014-2019  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 *
+from GeomDataAPI import *
+
+aSession = ModelAPI_Session.get()
+aDoc = aSession.moduleDocument()
+assert(not aSession.canUndo())
+assert(not aSession.canRedo())
+
+aSession.startOperation()
+aFeature = aDoc.addFeature("Point")
+geomDataAPI_Point(aFeature.attribute("point3d")).setValue(1., -1., 0.)
+aFeature.string("creation_method").setValue("by_xyz")
+aFeatureName = aFeature.name()
+# "2" is because Origin is the first point
+assert(aFeatureName == "Point_2")
+
+aFeature.execute()
+aSession.finishOperation()
+
+assert(aDoc.size("Construction") == 8)
+assert(aSession.canUndo())
+assert(not aSession.canRedo())
+
+aSession.undo()
+assert(aDoc.size("Construction") == 7)
+assert(not aSession.canUndo())
+assert(aSession.canRedo())
+
+aSession.redo()
+assert(aDoc.size("Construction") == 8)
+assert(aSession.canUndo())
+assert(not aSession.canRedo())
+
+from salome.shaper import model
+assert(model.checkPythonDump())