Salome HOME
Fix for hang up (and crash after) on remove of all features in the complicated model...
[modules/shaper.git] / src / ModelAPI / Test / TestDocument.py
index fd9415488e1bf42ea70464cee20369dec3b205c1..8080f3654ae3efc4ecf84c8842cdb5ccdae38728 100644 (file)
@@ -10,7 +10,7 @@ from ModelAPI import *
 # from GeomDataAPI import *
 # from GeomAlgoAPI import *
 
-__updated__ = "2014-12-16"
+__updated__ = "2014-12-26"
 
 #=========================================================================
 # Creation and activation of documents
@@ -38,8 +38,8 @@ aSession.finishOperation()
 assert(aSession.activeDocument())
 assert(aSession.activeDocument().id() == "root")
 # check all opened docs
-for aDoc in aSession.allOpenedDocuments():
-    assert(aDoc)
+allDocsList = aSession.allOpenedDocuments()
+assert(len(allDocsList) != 0)
 # Activate Part_1 doc back for further testing
 aSession.startOperation()
 aSession.setActiveDocument(aSession.document("Part_1"), False)
@@ -62,7 +62,7 @@ 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()
@@ -75,31 +75,16 @@ 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("Part_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
-#=========================================================================