]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixed PythonAPI tests
authordbv <dbv@opencascade.com>
Wed, 15 Jun 2016 14:12:06 +0000 (17:12 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:10 +0000 (14:41 +0300)
src/PythonAPI/Test/TestFeatures.py
src/PythonAPI/Test/TestFeaturesRevolution.py
src/PythonAPI/model/features/__init__.py

index c3d4c31367c337a7ec87260b57552cf6d2eb8aa0..c744fe82b8372a24c57654ab1f2b1c189adc7501 100644 (file)
@@ -53,7 +53,7 @@ class FeaturesTestCase(FeaturesFixture):
 
     def test_initialize_without_attributes(self):
         import ConstructionAPI
-        model.construction.axis.Axis(self.part.addFeature("Axis"))
+        ConstructionAPI.ConstructionAPI_Axis(self.part.addFeature("Axis"))
         ConstructionAPI.ConstructionAPI_Plane(self.part.addFeature("Plane"))
         ConstructionAPI.ConstructionAPI_Point(self.part.addFeature("Point"))
 
@@ -66,7 +66,7 @@ class FeaturesTestCase(FeaturesFixture):
         FeaturesAPI.FeaturesAPI_Extrusion(self.part.addFeature("Extrusion"))
         # model.features.extrusion_boolean.ExtrusionBoolean(self.part.addFeature("ExtrusionCut"))
         # model.features.extrusion_boolean.ExtrusionBoolean(self.part.addFeature("ExtrusionFuse"))
-        model.features.revolution.Revolution(self.part.addFeature("Revolution"))
+        FeaturesAPI.FeaturesAPI_Revolution(self.part.addFeature("Revolution"))
         # model.features.revolution_boolean.RevolutionBoolean(self.part.addFeature("RevolutionCut"))
         # model.features.revolution_boolean.RevolutionBoolean(self.part.addFeature("RevolutionFuse"))
         FeaturesAPI.FeaturesAPI_Placement(self.part.addFeature("Placement"))
index 1c2084183b3a6c4d0e8827c64ce52325431ec123..abb22a4a423beae7ff3eaced8361140345e5ccd4 100644 (file)
@@ -30,17 +30,15 @@ class FeaturesRevolutionFixture(FeaturesAddRevolutionFixture):
         # base
         base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         circle = base_sketch.addCircle(0, 0, 10)
-        # axis
-        axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
-        line = axis_sketch.addLine(20, -10, 20, 10)
 
         model.do()
 
         base = base_sketch.selectFace()
-        axis_object = Selection(axis_sketch.result()[0],
-                                line.result()[0])
+        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()
 
-        self.revolution = model.addRevolution(self.part, base, axis_object,
+        self.revolution = model.addRevolution(self.part, base, axis_object[0],
                                               0, 180)
 
         model.do()
@@ -53,13 +51,6 @@ class FeaturesRevolutionFixture(FeaturesAddRevolutionFixture):
 
 class FeaturesAddRevolutionTestCase(FeaturesAddRevolutionFixture):
 
-    def test_add_revolution_no_base(self):
-        try:
-            revolution = model.addRevolution(self.part)
-            fail("addRevolution should assert if base is not None")
-        except AssertionError:
-            pass
-
     def test_add_revolution_by_face_and_angles(self):
         # base
         base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
@@ -68,11 +59,11 @@ class FeaturesAddRevolutionTestCase(FeaturesAddRevolutionFixture):
         model.do()
 
         base = base_sketch.selectFace()
-        axis_point1 = model.addPoint(self.part, 20, -10, 0)
-        axis_point2 = model.addPoint(self.part, 20, 10, 0)
-        axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+        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()
 
-        revolution = model.addRevolution(self.part, base, axis_object,
+        revolution = model.addRevolution(self.part, base, axis_object[0],
                                          0, 180)
 
         self.assertEqual(revolution.creationMethod().value(), "ByAngles")
@@ -101,13 +92,13 @@ class FeaturesAddRevolutionTestCase(FeaturesAddRevolutionFixture):
         model.do()
 
         base = base_sketch.selectFace()
-        axis_point1 = model.addPoint(self.part, 20, -10, 0)
-        axis_point2 = model.addPoint(self.part, 20, 10, 0)
-        axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+        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()
         to_obejct = to_sketch.selectFace()[0]
         from_object = from_sketch.selectFace()[0]
 
-        revolution = model.addRevolution(self.part, base, axis_object,
+        revolution = model.addRevolution(self.part, base, axis_object[0],
                                          to_obejct, 15,
                                          from_object, 20)
 
@@ -130,9 +121,9 @@ class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
 
     def test_revolution_get_attribute(self):
         # call method of the feature
-        self.assertTrue(isinstance(self.revolution.base(),
+        self.assertTrue(isinstance(self.revolution.baseObjects(),
                                    ModelAPI.ModelAPI_AttributeSelectionList))
-        self.assertTrue(isinstance(self.revolution.axisObject(),
+        self.assertTrue(isinstance(self.revolution.axis(),
                                    ModelAPI.ModelAPI_AttributeSelection))
         self.assertTrue(isinstance(self.revolution.creationMethod(),
                                    ModelAPI.ModelAPI_AttributeString))
@@ -177,17 +168,17 @@ class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
         model.do()
 
         base = base_sketch.selectFace()
-        axis_point1 = model.addPoint(self.part, 20, -10, 0)
-        axis_point2 = model.addPoint(self.part, 20, 10, 0)
-        axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+        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()
         to_obejct = to_sketch.selectFace()[0]
         from_object = from_sketch.selectFace()[0]
 
         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.toAngle().value(), 0)
+        self.assertEqual(self.revolution.fromAngle().value(), 0)
 #         self.assertEqual(self.revolution.getToObject().context(), None)
         self.assertEqual(self.revolution.toOffset().value(), 15)
 #         self.assertEqual(self.revolution.getFromObject().context(), None)
index d0319d48e5f3303caaa098282b9b2908dd5682ba..ca00dd5bb813758e14c0e9ce5c6adc0c47cfa872 100644 (file)
@@ -5,10 +5,8 @@ from FeaturesAPI import addFuse, addCut, addCommon
 
 from partition import addPartition
 
-from FeaturesAPI import addExtrusion
+from FeaturesAPI import addExtrusion, addRevolution
 from extrusion_boolean import addExtrusionCut, addExtrusionFuse
-
-from revolution import addRevolution
 from revolution_boolean import addRevolutionCut, addRevolutionFuse
 
 from placement import addPlacement