1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## Lesser General Public License for more details.
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #=========================================================================
22 # Test checks stability of the foldering mechanism due to incorrect input parameters
23 #=========================================================================
24 from ModelAPI import *
26 __updated__ = "2017-11-23"
28 aSession = ModelAPI_Session.get()
31 def newPoint(theDocument, theX, theY, theZ):
32 aSession.startOperation()
33 aPoint = theDocument.addFeature("Point")
34 aPointData = aPoint.data()
35 assert(aPointData is not None)
36 aPointData.real("x").setValue(theX)
37 aPointData.real("y").setValue(theY)
38 aPointData.real("z").setValue(theZ)
39 aPointData.string("creation_method").setValue("by_xyz")
40 aSession.finishOperation()
44 #=========================================================================
45 # Initialization of the model
46 #=========================================================================
47 aSession.startOperation()
48 aPart = aSession.moduleDocument().addFeature("Part")
49 aSession.finishOperation()
51 # add point and a folder before it
52 aPartDoc = aSession.activeDocument()
53 aPoint1 = newPoint(aPartDoc, 0., 0., 0.)
55 aSession.startOperation()
56 aFolder1 = aPartDoc.addFolder(aPoint1)
57 aSession.finishOperation()
62 assert(aPartDoc.size("Folders") == 1), "Wrong number of folders: {}".format(aPartDoc.size("Folders"))
63 assert(aPartDoc.size("Features") == NB_FEATURES_FULL), "Wrong number of features: {}".format(aPartDoc.size("Features"))
65 #=========================================================================
66 # Test 1. Check number of features out of folder
67 # and absense of the crash while getting size of incorrect group
68 #=========================================================================
69 assert(aPartDoc.size("Features", True) == NB_FEATURES_OUT), "Wrong number of features: {}, expected: {}".format(aPartDoc.size("Features", True), NB_FEATURES_OUT)
70 assert(aPartDoc.size("Construction", True) == 1), "Wrong size: {}".format(aPartDoc.size("Construction", True))
72 #=========================================================================
73 # Test 2. Add a feature to the folder and check number of features once again
74 #=========================================================================
75 toFolder = FeatureList()
76 toFolder.append(aPoint1)
78 aSession.startOperation()
79 aFolder2 = aPartDoc.addFolder(aPoint1)
80 aSession.finishOperation()
85 aSession.startOperation()
86 aFolder = aPartDoc.findFolderAbove(toFolder)
87 assert(aFolder is not None)
88 isAdded = aPartDoc.moveToFolder(toFolder, aFolder)
89 aSession.finishOperation()
93 assert(aPartDoc.size("Features", True) == NB_FEATURES_OUT), "Wrong number of features: {}, expected: {}".format(aPartDoc.size("Features", True), NB_FEATURES_OUT)
94 assert(aPartDoc.size("Construction", True) == 1), "Wrong size: {}".format(aPartDoc.size("Construction", True))