From 38964e6af7aecd53023594625b4d90a17f503df5 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 26 Jul 2017 15:23:05 +0300 Subject: [PATCH] Put in order tests of API: there are to many end of transactions appeared, but no start. --- src/PythonAPI/model/tests/tests.py | 4 +- .../Transformations/TestTranslation_2.py | 53 +++---------------- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index f75e4ae0f..fa737c5ec 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -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) diff --git a/test.API/SHAPER/Transformations/TestTranslation_2.py b/test.API/SHAPER/Transformations/TestTranslation_2.py index e68805e9a..226f30928 100644 --- a/test.API/SHAPER/Transformations/TestTranslation_2.py +++ b/test.API/SHAPER/Transformations/TestTranslation_2.py @@ -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) -- 2.39.2