Salome HOME
[Code coverage FeaturesPlugin]: Improve coverage of Pipe algorithm
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPipe_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 from ModelAPI import *
22 from GeomDataAPI import *
23
24 # Get document
25 aSession = ModelAPI_Session.get()
26 aDocument = aSession.moduleDocument()
27
28 # Create a part
29 aSession.startOperation()
30 aPartFeature = aDocument.addFeature("Part")
31 aSession.finishOperation()
32 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
33 aPart = aPartResult.partDoc()
34
35 # Create a sketch with circle for pipe profile
36 aSession.startOperation()
37 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
38 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
39 origin.setValue(0, 0, 0)
40 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
41 dirx.setValue(1, 0, 0)
42 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
43 norm.setValue(0, 0, 1)
44
45 # Create circle
46 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
47 anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
48 aCircleRadius = aSketchCircleFeature.real("circle_radius")
49 anCircleCentr.setValue(0, 0)
50 aCircleRadius.setValue(10)
51 aSession.finishOperation()
52
53 aSketchResult = aSketchFeature.firstResult()
54 aSketchShape = aSketchResult.shape()
55
56 aSession.startOperation()
57 aPipeFeature = aPart.addFeature("Pipe")
58 aPipeFeature.string("creation_method").setValue("WrongCreationMethod")
59 aPipeFeature.execute()
60 assert(aPipeFeature.error() != "")
61 aSession.finishOperation()
62
63 aSession.startOperation()
64 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
65 aBaseObjectsList.append(aSketchResult, None)
66 aPipeFeature.execute()
67 assert(aPipeFeature.error() != "")
68 aSession.finishOperation()
69
70 aSession.startOperation()
71 aPathObjectSelection = aPipeFeature.selection("path_object")
72 aPathObjectSelection.selectSubShape("EDGE", "PartSet/OZ")
73 aPipeFeature.execute()
74 assert(aPipeFeature.error() != "")
75 aSession.finishOperation()
76
77 aSession.startOperation()
78 aPipeFeature.string("creation_method").setValue("binormal")
79 aPipeFeature.execute()
80 assert(aPipeFeature.error() != "")
81 aSession.finishOperation()
82
83 aSession.startOperation()
84 aPipeFeature.string("creation_method").setValue("locations")
85 aBaseObjectsList = aPipeFeature.selectionList("locations_objects")
86 aBaseObjectsList.append(None, None)
87 aPipeFeature.execute()
88 assert(aPipeFeature.error() != "")
89 aSession.finishOperation()