X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPythonAPI%2Fmodel%2Ftests%2Ftests.py;h=e088f7c749723377713df2a22937eb330ffa068c;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=dc36d0bd718aba75dee697213504d5db1eb05df8;hpb=06e7f5859095193fc7f498bd89a7d28009794f53;p=modules%2Fshaper.git diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index dc36d0bd7..e088f7c74 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2023 CEA, EDF +# Copyright (C) 2014-2024 CEA, EDF # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,7 +20,7 @@ from GeomAlgoAPI import * from GeomAPI import * from GeomDataAPI import * -from ModelAPI import ModelAPI_Feature, ModelAPI_Session +from ModelAPI import ModelAPI_Feature, ModelAPI_Session, objectToFeature from ModelHighAPI import * import math from salome.shaper.model import sketcher @@ -444,3 +444,32 @@ def checkFilter(thePartDoc, theModel, theFilter, theShapesList): assert aFiltersFactory.isValid(theFilter.feature(), parent, shape) == res, "Filter result for {} \"{}\" incorrect. Expected {}.".format(shapeType, shapeName, res) if needUndo: theModel.undo() + +def checkFeaturesValidity(thePartDoc): + """ Check that the features are not in error + """ + aFactory = ModelAPI_Session.get().validators() + + nbFeatures = thePartDoc.size("Features") + + assert nbFeatures>0, "No features found in part doc" + + for i in range(nbFeatures): + partObject = thePartDoc.object("Features", i) + # Check the data + partObjectData = partObject.data() + name = partObjectData.name() + error = partObjectData.error() + # raise the error message if there is one + assert error == '', "The feature data {0} is in error: {1}".format(name, error) + # raise an error if the the feature is not valid (without error message) + assert partObject.data().isValid(), "The feature data {0} is in error.".format(name) + # Same checks for the feature itself + feature = objectToFeature(partObject) + if feature is None: + # Folders are not real features + continue + # raise the error message if there is one + assert error == '', "The feature {0} is in error: {1}".format(name, error) + # raise an error if the the feature is not valid (without error message) + assert aFactory.validate(feature), "The feature {0} is in error.".format(name)