Salome HOME
[Code coverage ConstructionPlugin]: Unit tests to check error messages
[modules/shaper.git] / src / ConstructionPlugin / Test / TestAxis_ErrorMsg.py
1 ## Copyright (C) 2018-20xx  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
22 from ModelAPI import *
23 aSession = ModelAPI_Session.get()
24 aDocument = aSession.moduleDocument()
25
26 # Create a part
27 aSession.startOperation()
28 aPartFeature = aDocument.addFeature("Part")
29 aSession.finishOperation()
30 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
31 aPart = aPartResult.partDoc()
32
33 # Create auxiliary box
34 aSession.startOperation()
35 aBox = aPart.addFeature("Box")
36 aBox.string("CreationMethod").setValue("BoxByDimensions")
37 aBox.real("dx").setValue(50)
38 aBox.real("dy").setValue(50)
39 aBox.real("dz").setValue(50)
40 aSession.finishOperation()
41
42 # Create auxiliary compound
43 aSession.startOperation()
44 aCompound = aPart.addFeature("Compound")
45 aCompoundList = aCompound.selectionList("base_objects")
46 aCompoundList.append("Box_1_1/Front", "FACE")
47 aCompoundList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE")
48 aSession.finishOperation()
49
50 # Create auxiliary box 2
51 aSession.startOperation()
52 aBox = aPart.addFeature("Box")
53 aBox.string("CreationMethod").setValue("BoxByDimensions")
54 aBox.real("dx").setValue(50)
55 aBox.real("dy").setValue(50)
56 aBox.real("dz").setValue(50)
57 aSession.finishOperation()
58
59 # Create auxiliary compound 2
60 aSession.startOperation()
61 aCompound = aPart.addFeature("Compound")
62 aCompoundList = aCompound.selectionList("base_objects")
63 aCompoundList.append("[Box_2_1/Left][Box_2_1/Top]", "EDGE")
64 aCompoundList.append("Box_2_1/Front", "FACE")
65 aSession.finishOperation()
66
67
68 # Axis by cylindrical face
69 aSession.startOperation()
70 Axis_1 = aPart.addFeature("Axis")
71 Axis_1.string("CreationMethod").setValue("AxisByCylindricalFaceCase")
72 Axis_1.selection("CylindricalFace").selectSubShape("COMPOUND", "Compound_2_1")
73 Axis_1.execute()
74 aSession.finishOperation()
75 assert(Axis_1.error() != "")
76
77 # Axis by dimensions
78 aSession.startOperation()
79 Axis_1.string("CreationMethod").setValue("AxisByDimensionsCase")
80 Axis_1.real("DX").setValue(0)
81 Axis_1.real("DY").setValue(0)
82 Axis_1.real("DZ").setValue(0)
83 Axis_1.execute()
84 assert(Axis_1.error() != "")
85 aSession.finishOperation()
86
87 # Axis by line
88 aSession.startOperation()
89 Axis_1.string("CreationMethod").setValue("by_line")
90 Axis_1.selection("line").selectSubShape("COMPOUND", "Compound_1_1")
91 Axis_1.execute()
92 assert(Axis_1.error() != "")
93 aSession.finishOperation()
94
95 # Axis by plane and point
96 aSession.startOperation()
97 Axis_1.string("CreationMethod").setValue("by_plane_and_point")
98 Axis_1.selection("point").selectSubShape("COMPOUND", "Compound_1_1")
99 Axis_1.selection("plane").selectSubShape("COMPOUND", "Compound_2_1")
100 Axis_1.execute()
101 assert(Axis_1.error() != "")
102 aSession.finishOperation()
103
104 # Axis by two planes
105 aSession.startOperation()
106 Axis_1.string("CreationMethod").setValue("by_two_planes")
107 Axis_1.selection("plane1").selectSubShape("COMPOUND", "Compound_2_1")
108 Axis_1.selection("plane2").selectSubShape("COMPOUND", "Compound_2_1")
109 Axis_1.execute()
110 assert(Axis_1.error() != "")
111 aSession.finishOperation()
112
113 aSession.startOperation()
114 Axis_1.selection("plane1").selectSubShape("COMPOUND", "Compound_1_1")
115 Axis_1.string("use_offset1").setValue("true")
116 Axis_1.real("offset1").setValue(10)
117 Axis_1.boolean("reverse_offset1").setValue(True)
118 Axis_1.execute()
119 assert(Axis_1.error() != "")
120 aSession.finishOperation()