1 # Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 from salome.shaper import model
26 #-----------------------------------------------------------------------------
29 class FeaturesFixture(unittest.TestCase):
34 partset = model.moduleDocument()
35 self.part = model.addPart(partset).document()
40 # assert(model.checkPythonDump())
41 # This test checks creation of High API classes from low-level.
42 # It does not set any attributes, so features invalid, and dump also invalid.
45 #-----------------------------------------------------------------------------
48 class FeaturesTestCase(FeaturesFixture):
50 # def test_assert_error_on_empty_args(self):
52 # # Implemented in C++, add* without arguments doesn't exist
53 # # "addPoint", "addPlane",
54 # # "addImport", "exportToFile",
57 # "addCut", "addFuse", "addCommon",
59 # # "addExtrusionCut", "addExtrusionFuse",
61 # # "addRevolutionCut", "addRevolutionFuse",
62 # "addPlacement", "addRotation", "addTranslation",
66 # for name in features:
68 # with self.assertRaises(AssertionError):
69 # feature = getattr(model, name)(self.part)
70 # except AssertionError as e:
71 # self.fail("%s does not check empty args" % name)
73 def test_addPoint(self):
74 model.addPoint(self.part, 10, "20", "x + 30")
76 def test_initialize_without_attributes(self):
77 import ConstructionAPI
78 ConstructionAPI.ConstructionAPI_Axis(self.part.addFeature("Axis"))
79 ConstructionAPI.ConstructionAPI_Plane(self.part.addFeature("Plane"))
80 ConstructionAPI.ConstructionAPI_Point(self.part.addFeature("Point"))
83 ExchangeAPI.ExchangeAPI_Import(self.part.addFeature("Import"))
86 FeaturesAPI.FeaturesAPI_BooleanCut(self.part.addFeature("BooleanCut"))
87 FeaturesAPI.FeaturesAPI_BooleanFuse(self.part.addFeature("BooleanFuse"))
88 FeaturesAPI.FeaturesAPI_BooleanCommon(self.part.addFeature("BooleanCommon"))
89 FeaturesAPI.FeaturesAPI_BooleanFill(self.part.addFeature("BooleanFill"))
90 FeaturesAPI.FeaturesAPI_BooleanSmash(self.part.addFeature("BooleanSmash"))
91 FeaturesAPI.FeaturesAPI_Extrusion(self.part.addFeature("Extrusion"))
92 FeaturesAPI.FeaturesAPI_ExtrusionCut(self.part.addFeature("ExtrusionCut"))
93 FeaturesAPI.FeaturesAPI_ExtrusionFuse(self.part.addFeature("ExtrusionFuse"))
94 FeaturesAPI.FeaturesAPI_Revolution(self.part.addFeature("Revolution"))
95 FeaturesAPI.FeaturesAPI_RevolutionCut(self.part.addFeature("RevolutionCut"))
96 FeaturesAPI.FeaturesAPI_RevolutionFuse(self.part.addFeature("RevolutionFuse"))
97 FeaturesAPI.FeaturesAPI_Placement(self.part.addFeature("Placement"))
98 FeaturesAPI.FeaturesAPI_Rotation(self.part.addFeature("Rotation"))
99 FeaturesAPI.FeaturesAPI_Translation(self.part.addFeature("Translation"))
102 CollectionAPI.CollectionAPI_Group(self.part.addFeature("Group"))
105 PrimitivesAPI.PrimitivesAPI_Box(self.part.addFeature("Box"))
108 ParametersAPI.ParametersAPI_Parameter(self.part.addFeature("Parameter"))
110 #-----------------------------------------------------------------------------
112 if __name__ == "__main__":
113 test_program = unittest.main(exit=False)
114 assert test_program.result.wasSuccessful(), "Test failed"