Salome HOME
Issue #803: Put all the python modules in the same python package newgeom
[modules/shaper.git] / src / PartSetAPI / Test / TestRemoveDuplicate.py
1 # Created a Part Remove/Duplicate API functionality since from low level and python dump it is not
2 # tested: feature history infor is not stored.
3
4 from salome.shaper import model
5
6 # prepare axis created by PartSet and Part points
7 model.begin()
8 PartSet = model.moduleDocument()
9 Part_1 = model.addPart(PartSet)
10 Part_1_doc = Part_1.document()
11 Point_2 = model.addPoint(Part_1_doc, 100, 50, 20)
12 Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("VERTEX", "Point_1"))
13 model.do()
14
15 # Duplicate this part twice, duplicate the first Copy also
16 Copy_1 = model.duplicatePart(Part_1)
17 Copy_2 = model.duplicatePart(Part_1)
18 Copy_3 = model.duplicatePart(Copy_1)
19 model.do()
20
21 # check the intermediate result
22 assert PartSet.size("Parts") == 4
23 i = 0
24 for n in ["Part_1", "Part_3", "Part_2", "Part_4"]:
25   assert PartSet.object("Parts", i).data().name() == n
26   i = i + 1
27
28 # Remove the middle Part
29 model.removePart(Copy_2)
30 model.do()
31
32 # check the intermediate result
33 assert PartSet.size("Parts") == 3
34 i = 0
35 for n in ["Part_1", "Part_2", "Part_4"]:
36   assert PartSet.object("Parts", i).data().name() == n
37   i = i + 1
38
39 # Remove a first copy
40 model.removePart(Copy_1)
41 model.end()
42
43 # Undo the last remove
44 model.undo()
45
46 # Check the result
47 assert PartSet.size("Parts") == 3
48 i = 0
49 for n in ["Part_1", "Part_2", "Part_4"]:
50   assert PartSet.object("Parts", i).data().name() == n
51   i = i + 1