From f2e401ffee214c35112774224eb98974803eaca8 Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Tue, 21 Feb 2017 09:46:10 +0100 Subject: [PATCH] Added a test to check the naming of faces. --- src/PythonAPI/model/tests/tests.py | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index e4dcd7404..88e0731d4 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -106,3 +106,36 @@ def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDi anExpectedResultVolume = theExpectedResultsVolumes[anIndex] anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0") assert (aResultVolumeStr[:theNbSignificantDigits] == anExpectedResultVolumeStr[:theNbSignificantDigits]), "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits) + +def testHaveNamingFaces(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.FACE) + # 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.isFace()) + assert(name != ""), "String empty" -- 2.39.2