X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPythonAPI%2Fmodel%2Ftests%2Ftests.py;h=49fdcdd1306ebc165b4a42158f609de2001c8357;hb=a7d8192df8726f03ccffad3e0d754a760841882e;hp=ce6c3933288a6944447620e92cdccd649407128d;hpb=b3695c3af5289903f1c0fa01bbb7c40203c5e544;p=modules%2Fshaper.git diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index ce6c39332..49fdcdd13 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -166,7 +166,7 @@ def testHaveNamingFaces(theFeature, theModel, thePartDoc) : assert(name != ""), "String empty" def testHaveNamingEdges(theFeature, theModel, thePartDoc) : - """ Tests if all faces of result have a name + """ Tests if all edges of result have a name :param theFeature: feature to test. """ # Get feature result/sub-result @@ -198,6 +198,49 @@ def testHaveNamingEdges(theFeature, theModel, thePartDoc) : assert(shape.isEdge()) assert(name != ""), "String empty" +def testHaveNamingVertices(theFeature, theModel, thePartDoc) : + """ Tests if all vertices of result have a unique 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.VERTEX) + # Create list, and store selections in it + selectionList = [] + shapesList = [] # to append only unique shapes (not isSame) + while shapeExplorer.more(): + aDuplicate = False + for alreadyThere in shapesList: + if alreadyThere.isSame(shapeExplorer.current()): + aDuplicate = True + if aDuplicate: + shapeExplorer.next() + continue + shapesList.append(shapeExplorer.current()) + 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() + + # Check that all selected shapes in group have right shape type and unique name. + groupFeature = Group_1.feature() + groupSelectionList = groupFeature.selectionList("group_list") + assert(groupSelectionList.size() == len(selectionList)) + presented_names = set() + for index in range(0, groupSelectionList.size()): + attrSelection = groupSelectionList.value(index) + shape = attrSelection.value() + name = attrSelection.namingName() + assert(shape.isVertex()) + assert(name != ""), "String empty" + presented_names.add(name) + assert(len(presented_names) == groupSelectionList.size()), "Some names are not unique" + def testNbSubFeatures(theComposite, theKindOfSub, theExpectedCount): """ Tests number of sub-features of the given type