X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FTest%2FTestDocument.py;h=f872757830d78189046b63c3b8059740e0c05458;hb=6dce44a08e0505613a25d6d093f153d69045b1ce;hp=d3693974e5f2abb6e856b9eeff5cf3ad7b59a549;hpb=909e3c4143da4ae7896b9dbe0619e5028827c4b4;p=modules%2Fshaper.git diff --git a/src/ModelAPI/Test/TestDocument.py b/src/ModelAPI/Test/TestDocument.py index d3693974e..f87275783 100644 --- a/src/ModelAPI/Test/TestDocument.py +++ b/src/ModelAPI/Test/TestDocument.py @@ -1,14 +1,32 @@ +# Copyright (C) 2014-2020 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 +# + """ TestDocument.py Unit test for Model_Document/ModelAPI_Document class - + """ #========================================================================= # Initialization of the test #========================================================================= from ModelAPI import * -# from GeomDataAPI import * -# from GeomAlgoAPI import * +from GeomDataAPI import * __updated__ = "2014-12-26" @@ -16,9 +34,8 @@ __updated__ = "2014-12-26" # Creation and activation of documents #========================================================================= aSession = ModelAPI_Session.get() -# TODO: enable this assertion: assert(aSession.moduleDocument()) -assert(aSession.moduleDocument().id() == "root") +assert(aSession.moduleDocument().id() == 0) assert(aSession.moduleDocument().kind() == "PartSet") assert(aSession.hasModuleDocument()) # Create a new document @@ -27,22 +44,22 @@ aSession.moduleDocument().addFeature("Part") aSession.finishOperation() assert(aSession.activeDocument()) -assert(aSession.activeDocument().id() == "Part_1") +assert(aSession.activeDocument().id() == 1) assert(aSession.activeDocument().kind() == "Part") # Activate root doc -aRootDoc = aSession.document("root") +aRootDoc = aSession.document(0) assert(aRootDoc) aSession.startOperation() aSession.setActiveDocument(aRootDoc, False) aSession.finishOperation() assert(aSession.activeDocument()) -assert(aSession.activeDocument().id() == "root") +assert(aSession.activeDocument().id() == 0) # check all opened docs allDocsList = aSession.allOpenedDocuments() assert(len(allDocsList) != 0) # Activate Part_1 doc back for further testing aSession.startOperation() -aSession.setActiveDocument(aSession.document("Part_1"), False) +aSession.setActiveDocument(aSession.document(1), False) aSession.finishOperation() #========================================================================= # Duplication of a document @@ -54,19 +71,17 @@ aSession.startOperation() aFeature = aPart.addFeature("Point") aFeatureData = aFeature.data() assert(aFeatureData is not None) -aFeatureData.real("x").setValue(15.) -aFeatureData.real("y").setValue(10.) -aFeatureData.real("z").setValue(20.) +geomDataAPI_Point(aFeatureData.attribute("point3d")).setValue(15., 10., 20.) aSession.finishOperation() assert(aPart.size("Features") == 1) # Duplicate the document assert(aSession.moduleDocument().size("Parts") == 1) aSession.startOperation() -aSession.moduleDocument().addFeature("Duplicate") +aPart.addFeature("Duplicate") aSession.finishOperation() assert(aSession.moduleDocument().size("Parts") == 2) aCopyOfPart = aSession.activeDocument() -assert(aCopyOfPart.id() == "Part_2") +assert(aCopyOfPart.id() == 2) assert(aCopyOfPart.kind() == "Part") assert(aCopyOfPart.size("Features") == 1) assert(aCopyOfPart != aPart) @@ -75,31 +90,19 @@ assert(aCopyOfPart != aPart) #========================================================================= assert(aSession.moduleDocument().size("Parts") == 2) aSession.startOperation() -aSession.moduleDocument().addFeature("Remove") +aPart.addFeature("Remove") aSession.finishOperation() +# First part is deleted, but active is Part_2, so, it is still active assert(aSession.moduleDocument().size("Parts") == 1) -assert(aSession.activeDocument().id() == aSession.moduleDocument().id()) +assert(aSession.activeDocument().id() == aCopyOfPart.id()) # Remove another one document aSession.startOperation() -aDoc1 = aSession.document("Part_1") -aSession.setActiveDocument(aDoc1, False) -aSession.moduleDocument().addFeature("Remove") +aDoc2 = aSession.document(2) +aSession.setActiveDocument(aDoc2, False) +aDoc2.addFeature("Remove") aSession.finishOperation() assert(aSession.moduleDocument().size("Parts") == 0) assert(aSession.activeDocument()) -#========================================================================= -# Trying to duplicate/remove the root -#========================================================================= -aSession.startOperation() -aSession.moduleDocument().addFeature("Duplicate") -aSession.finishOperation() -assert(aSession.activeDocument().id() == aSession.moduleDocument().id()) -assert(aSession.moduleDocument().size("Parts") == 0) -aSession.startOperation() -aSession.moduleDocument().addFeature("Remove") -aSession.finishOperation() -assert(aSession.activeDocument().id() == aSession.moduleDocument().id()) -assert(aSession.moduleDocument().size("Parts") == 0) -#========================================================================= -# End of test -#========================================================================= + +from salome.shaper import model +assert(model.checkPythonDump())