Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / PartSetAPI / Test / TestRemoveDuplicate.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
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.
7 ##
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.
12 ##
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
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 # Created a Part Remove/Duplicate API functionality since from low level and python dump it is not
22 # tested: feature history infor is not stored.
23
24 from salome.shaper import model
25
26 # prepare axis created by PartSet and Part points
27 model.begin()
28 PartSet = model.moduleDocument()
29 Part_1 = model.addPart(PartSet)
30 Part_1_doc = Part_1.document()
31 Point_2 = model.addPoint(Part_1_doc, 100, 50, 20)
32 Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_1"))
33 model.do()
34
35 # Duplicate this part twice, duplicate the first Copy also
36 Copy_1 = model.duplicatePart(Part_1)
37 Copy_2 = model.duplicatePart(Part_1)
38 Copy_3 = model.duplicatePart(Copy_1)
39 model.do()
40
41 # check the intermediate result
42 assert PartSet.size("Parts") == 4
43 i = 0
44 for n in ["Part_1", "Part_3", "Part_2", "Part_4"]:
45   assert PartSet.object("Parts", i).data().name() == n
46   i = i + 1
47
48 # Remove the middle Part
49 model.removePart(Copy_2)
50 model.do()
51
52 # check the intermediate result
53 assert PartSet.size("Parts") == 3
54 i = 0
55 for n in ["Part_1", "Part_2", "Part_4"]:
56   assert PartSet.object("Parts", i).data().name() == n
57   i = i + 1
58
59 # Remove a first copy
60 model.removePart(Copy_1)
61 model.end()
62
63 # Undo the last remove
64 model.undo()
65
66 # Check the result
67 assert PartSet.size("Parts") == 3
68 i = 0
69 for n in ["Part_1", "Part_2", "Part_4"]:
70   assert PartSet.object("Parts", i).data().name() == n
71   i = i + 1