Salome HOME
Update copyrights
[modules/shaper.git] / src / PythonAPI / Test / TestFeaturesRevolution.py
index f1d4f9c5d46edb9551678ac981f4797f23281d96..b77d3e33e8457aaacea138cd2581b62e95e08ee6 100644 (file)
@@ -1,22 +1,21 @@
-## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
-##
-## This library is free software; you can redistribute it and/or
-## modify it under the terms of the GNU Lesser General Public
-## License as published by the Free Software Foundation; either
-## version 2.1 of the License, or (at your option) any later version.
-##
-## This library is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## Lesser General Public License for more details.
-##
-## You should have received a copy of the GNU Lesser General Public
-## License along with this library; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
 
 import unittest
 
@@ -56,10 +55,9 @@ class FeaturesRevolutionFixture(FeaturesAddRevolutionFixture):
         base = base_sketch.selectFace()
         axis_point1 = model.addPoint(self.part, 20, -10, 0).result()
         axis_point2 = model.addPoint(self.part, 20, 10, 0).result()
-        axis_object = model.addAxis(self.part, axis_point1[0], axis_point2[0]).result()
+        axis_object = model.addAxis(self.part, axis_point1, axis_point2).result()
 
-        self.revolution = model.addRevolution(self.part, base, axis_object[0],
-                                              0, 180)
+        self.revolution = model.addRevolution(self.part, base, axis_object, 0, 180)
 
         model.do()
 
@@ -81,18 +79,15 @@ class FeaturesAddRevolutionTestCase(FeaturesAddRevolutionFixture):
         base = base_sketch.selectFace()
         axis_point1 = model.addPoint(self.part, 20, -10, 0).result()
         axis_point2 = model.addPoint(self.part, 20, 10, 0).result()
-        axis_object = model.addAxis(self.part, axis_point1[0], axis_point2[0]).result()
+        axis_object = model.addAxis(self.part, axis_point1, axis_point2).result()
 
-        revolution = model.addRevolution(self.part, base, axis_object[0],
-                                         0, 180)
+        revolution = model.addRevolution(self.part, base, axis_object, 0, 180)
 
         self.assertEqual(revolution.creationMethod().value(), "ByAngles")
         self.assertEqual(revolution.toAngle().value(), 0)
         self.assertEqual(revolution.fromAngle().value(), 180)
         self.assertEqual(revolution.toObject().context(), None)
-        self.assertEqual(revolution.toOffset().value(), 0)
         self.assertEqual(revolution.fromObject().context(), None)
-        self.assertEqual(revolution.fromOffset().value(), 0)
 
     def test_add_revolution_by_face_and_planes(self):
         # base
@@ -114,23 +109,19 @@ class FeaturesAddRevolutionTestCase(FeaturesAddRevolutionFixture):
         base = base_sketch.selectFace()
         axis_point1 = model.addPoint(self.part, 20, -10, 0).result()
         axis_point2 = model.addPoint(self.part, 20, 10, 0).result()
-        axis_object = model.addAxis(self.part, axis_point1[0], axis_point2[0]).result()
+        axis_object = model.addAxis(self.part, axis_point1, axis_point2).result()
         to_obejct = to_sketch.selectFace()[0]
         from_object = from_sketch.selectFace()[0]
 
-        revolution = model.addRevolution(self.part, base, axis_object[0],
-                                         to_obejct, 15,
-                                         from_object, 20)
+        self.revolution = model.addRevolution(self.part, base, axis_object,
+                                              to_obejct, 15,
+                                              from_object, 20)
 
-        self.assertEqual(revolution.creationMethod().value(), "ByPlanesAndOffsets")
-        self.assertEqual(revolution.toAngle().value(), 0)
-        self.assertEqual(revolution.fromAngle().value(), 0)
-#         self.assertEqual(revolution.getToObject().context(),
-#                          to_sketch.result())
-        self.assertEqual(revolution.toOffset().value(), 15)
-#         self.assertEqual(revolution.getFromObject().context(),
-#                          from_sketch.result())
-        self.assertEqual(revolution.fromOffset().value(), 20)
+        self.assertEqual(self.revolution.creationMethod().value(), "ByPlanesAndOffsets")
+        self.assertNotEqual(self.revolution.toObject().context(), None)
+        self.assertEqual(self.revolution.toOffset().value(), 15)
+        self.assertNotEqual(self.revolution.fromObject().context(), None)
+        self.assertEqual(self.revolution.fromOffset().value(), 20)
 
 
 class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
@@ -166,9 +157,7 @@ class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
         self.assertEqual(self.revolution.toAngle().value(), 90)
         self.assertEqual(self.revolution.fromAngle().value(), 270)
         self.assertEqual(self.revolution.toObject().context(), None)
-        self.assertEqual(self.revolution.toOffset().value(), 0)
         self.assertEqual(self.revolution.fromObject().context(), None)
-        self.assertEqual(self.revolution.fromOffset().value(), 0)
 
     def test_revolution_set_planes_and_offsets(self):
         # base
@@ -190,20 +179,20 @@ class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
         base = base_sketch.selectFace()
         axis_point1 = model.addPoint(self.part, 20, -10, 0).result()
         axis_point2 = model.addPoint(self.part, 20, 10, 0).result()
-        axis_object = model.addAxis(self.part, axis_point1[0], axis_point2[0]).result()
+        axis_object = model.addAxis(self.part, axis_point1, axis_point2).result()
         to_obejct = to_sketch.selectFace()[0]
         from_object = from_sketch.selectFace()[0]
 
+        self.revolution = model.addRevolution(self.part, base, axis_object, 0, 180)
         self.revolution.setPlanesAndOffsets(to_obejct, 15, from_object, 20)
 
         self.assertEqual(self.revolution.creationMethod().value(), "ByPlanesAndOffsets")
-        # self.assertEqual(self.revolution.toAngle().value(), 0)
-        # self.assertEqual(self.revolution.fromAngle().value(), 0)
-#         self.assertEqual(self.revolution.getToObject().context(), None)
+        self.assertNotEqual(self.revolution.toObject().context(), None)
         self.assertEqual(self.revolution.toOffset().value(), 15)
-#         self.assertEqual(self.revolution.getFromObject().context(), None)
+        self.assertNotEqual(self.revolution.fromObject().context(), None)
         self.assertEqual(self.revolution.fromOffset().value(), 20)
 
 
 if __name__ == "__main__":
-    unittest.main()
+    test_program = unittest.main(exit=False)
+    assert test_program.result.wasSuccessful(), "Test failed"