From: Clarisse Genrault Date: Fri, 28 Jul 2017 14:15:59 +0000 (+0200) Subject: Add the method testHaveNamingEdges. X-Git-Tag: V_2.7.2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e2405ab9f715cba3d42ce6c98d7b4d4810fb79e;p=modules%2Fshaper.git Add the method testHaveNamingEdges. --- diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index fa737c5ec..ce6c39332 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -165,6 +165,40 @@ def testHaveNamingFaces(theFeature, theModel, thePartDoc) : assert(shape.isFace()) assert(name != ""), "String empty" +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" + + def testNbSubFeatures(theComposite, theKindOfSub, theExpectedCount): """ Tests number of sub-features of the given type :param theComposite composite feature to check its subs