Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / PythonAPI / Test / TestFeatures.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 import unittest
22
23 import ModelAPI
24
25 from salome.shaper import model
26
27 #-----------------------------------------------------------------------------
28 # Fixtures
29
30 class FeaturesFixture(unittest.TestCase):
31
32     def setUp(self):
33         model.begin()
34         # Create part
35         partset = model.moduleDocument()
36         self.part = model.addPart(partset).document()
37         model.do()
38
39     def tearDown(self):
40         model.end()
41         # assert(model.checkPythonDump())
42         # This test checks creation of High API classes from low-level.
43         # It does not set any attributes, so features invalid, and dump also invalid.
44         model.reset()
45
46 #-----------------------------------------------------------------------------
47 # TestCases
48
49 class FeaturesTestCase(FeaturesFixture):
50
51     # def test_assert_error_on_empty_args(self):
52     #     features = [
53     #         # Implemented in C++, add* without arguments doesn't exist
54     #         # "addPoint", "addPlane",
55     #         # "addImport", "exportToFile",
56     #
57     #         "addAxis",
58     #         "addCut", "addFuse", "addCommon",
59     #         "addExtrusion",
60     #         # "addExtrusionCut", "addExtrusionFuse",
61     #         "addRevolution",
62     #         # "addRevolutionCut", "addRevolutionFuse",
63     #         "addPlacement", "addRotation", "addTranslation",
64     #         "addGroup",
65     #         "addParameter",
66     #         ]
67     #     for name in features:
68     #         try:
69     #             with self.assertRaises(AssertionError):
70     #                 feature = getattr(model, name)(self.part)
71     #         except AssertionError as e:
72     #             self.fail("%s does not check empty args" % name)
73
74     def test_addPoint(self):
75         model.addPoint(self.part, 10, "20", "x + 30")
76
77     def test_initialize_without_attributes(self):
78         import ConstructionAPI
79         ConstructionAPI.ConstructionAPI_Axis(self.part.addFeature("Axis"))
80         ConstructionAPI.ConstructionAPI_Plane(self.part.addFeature("Plane"))
81         ConstructionAPI.ConstructionAPI_Point(self.part.addFeature("Point"))
82
83         import ExchangeAPI
84         ExchangeAPI.ExchangeAPI_Import(self.part.addFeature("Import"))
85
86         import FeaturesAPI
87         FeaturesAPI.FeaturesAPI_Boolean(self.part.addFeature("Boolean"))
88         FeaturesAPI.FeaturesAPI_Extrusion(self.part.addFeature("Extrusion"))
89         FeaturesAPI.FeaturesAPI_ExtrusionCut(self.part.addFeature("ExtrusionCut"))
90         FeaturesAPI.FeaturesAPI_ExtrusionFuse(self.part.addFeature("ExtrusionFuse"))
91         FeaturesAPI.FeaturesAPI_Revolution(self.part.addFeature("Revolution"))
92         FeaturesAPI.FeaturesAPI_RevolutionCut(self.part.addFeature("RevolutionCut"))
93         FeaturesAPI.FeaturesAPI_RevolutionFuse(self.part.addFeature("RevolutionFuse"))
94         FeaturesAPI.FeaturesAPI_Placement(self.part.addFeature("Placement"))
95         FeaturesAPI.FeaturesAPI_Rotation(self.part.addFeature("Rotation"))
96         FeaturesAPI.FeaturesAPI_Translation(self.part.addFeature("Translation"))
97
98         import CollectionAPI
99         CollectionAPI.CollectionAPI_Group(self.part.addFeature("Group"))
100
101         import PrimitivesAPI
102         PrimitivesAPI.PrimitivesAPI_Box(self.part.addFeature("Box"))
103
104         import ParametersAPI
105         ParametersAPI.ParametersAPI_Parameter(self.part.addFeature("Parameter"))
106
107 #-----------------------------------------------------------------------------
108
109 if __name__ == "__main__":
110     unittest.main()