]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Put in order tests of API: there are to many end of transactions appeared, but no...
authormpv <mpv@opencascade.com>
Wed, 26 Jul 2017 12:23:05 +0000 (15:23 +0300)
committermpv <mpv@opencascade.com>
Wed, 26 Jul 2017 12:23:05 +0000 (15:23 +0300)
src/PythonAPI/model/tests/tests.py
test.API/SHAPER/Transformations/TestTranslation_2.py

index f75e4ae0fea8a95887d2336784a33b630c01816f..fa737c5ec46cfc08ece6eaf955a1e0f6c85ca2c0 100644 (file)
@@ -136,6 +136,8 @@ def testHaveNamingFaces(theFeature, theModel, thePartDoc) :
   """ Tests if all faces of result have a name
   :param theFeature: feature to test.
   """
+  # open transaction since all the checking are performed in tests after model.end() call
+  theModel.begin()
   # Get feature result/sub-result
   aResult = theFeature.results()[0].resultSubShapePair()[0]
   # Get result/sub-result shape
@@ -150,13 +152,11 @@ def testHaveNamingFaces(theFeature, theModel, thePartDoc) :
     shapeExplorer.next()
   # Create group with this selection list
   Group_1 = theModel.addGroup(thePartDoc, selectionList)
-  theModel.do()
   theModel.end()
 
   # Now you can check that all selected shapes in group have right shape type and name.
   groupFeature = Group_1.feature()
   groupSelectionList = groupFeature.selectionList("group_list")
-  theModel.end()
   assert(groupSelectionList.size() == len(selectionList))
   for index in range(0, groupSelectionList.size()):
     attrSelection = groupSelectionList.value(index)
index e68805e9ad7b3abea1e067a3b94e91096d3117d7..226f3092852b06be6da0a357442ec1336c91425c 100644 (file)
@@ -182,98 +182,61 @@ model.do()
 model.end()
 
 
-# Checks
-from GeomAPI import GeomAPI_Shape
-from GeomAPI import GeomAPI_ShapeExplorer
-
-def testHaveNamingEdges(theFeature, theModel, thePartDoc) :
-  """ Tests if all faces of result have a name
-  :param theFeature: feature to test.
-  """
-  # Get feature result/sub-result
-  aResult = theFeature.results()[0].resultSubShapePair()[0]
-  # Get result/sub-result shape
-  shape = aResult.shape()
-  # Create shape explorer with desired shape type
-  shapeExplorer = GeomAPI_ShapeExplorer(shape, GeomAPI_Shape.EDGE)
-  # Create list, and store selections in it
-  selectionList = []
-  while shapeExplorer.more():
-    selection = theModel.selection(aResult, shapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result
-    selectionList.append(selection)
-    shapeExplorer.next()
-  # Create group with this selection list
-  Group_1 = theModel.addGroup(thePartDoc, selectionList)
-  theModel.do()
-  theModel.end()
-
-  # Now you can check that all selected shapes in group have right shape type and name.
-  groupFeature = Group_1.feature()
-  groupSelectionList = groupFeature.selectionList("group_list")
-  theModel.end()
-  assert(groupSelectionList.size() == len(selectionList))
-  for index in range(0, groupSelectionList.size()):
-    attrSelection = groupSelectionList.value(index)
-    shape = attrSelection.value()
-    name = attrSelection.namingName()
-    assert(shape.isEdge())
-    assert(name != ""), "String empty"
-
 # Translation 27
 model.testNbResults(Translation_27, 1)
 model.testNbSubResults(Translation_27, [12])
 model.testNbSubShapes(Translation_27, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_27, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_27, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_27, model, Part_1_doc)
 
 # Translation 28
 model.testNbResults(Translation_28, 1)
 model.testNbSubResults(Translation_28, [12])
 model.testNbSubShapes(Translation_28, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_28, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_28, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_28, model, Part_1_doc)
 
 # Translation 29
 model.testNbResults(Translation_29, 1)
 model.testNbSubResults(Translation_29, [12])
 model.testNbSubShapes(Translation_29, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_29, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_29, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_29, model, Part_1_doc)
 
 # Translation 31
 model.testNbResults(Translation_31, 1)
 model.testNbSubResults(Translation_31, [12])
 model.testNbSubShapes(Translation_31, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_31, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_31, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_31, model, Part_1_doc)
 
 # Translation 32
 model.testNbResults(Translation_32, 1)
 model.testNbSubResults(Translation_32, [12])
 model.testNbSubShapes(Translation_32, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_32, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_32, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_32, model, Part_1_doc)
 
 # Translation 33
 model.testNbResults(Translation_33, 1)
 model.testNbSubResults(Translation_33, [12])
 model.testNbSubShapes(Translation_33, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_33, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_33, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_33, model, Part_1_doc)
 
 # Translation 34
 model.testNbResults(Translation_34, 1)
 model.testNbSubResults(Translation_34, [12])
 model.testNbSubShapes(Translation_34, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_34, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_34, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_34, model, Part_1_doc)
 
 # Translation 35
 model.testNbResults(Translation_35, 1)
 model.testNbSubResults(Translation_35, [12])
 model.testNbSubShapes(Translation_35, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_35, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_35, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_35, model, Part_1_doc)
 
 # Translation 36
 model.testNbResults(Translation_36, 1)