From be09d02207dd92533e4b2977f21085768fda0c85 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 23 Nov 2016 14:35:45 +0300 Subject: [PATCH] Added unit test for the issue #1806 --- src/ParametersPlugin/CMakeLists.txt | 1 + src/ParametersPlugin/Test/Test1806.py | 51 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/ParametersPlugin/Test/Test1806.py diff --git a/src/ParametersPlugin/CMakeLists.txt b/src/ParametersPlugin/CMakeLists.txt index d57d1d4ec..e5c32be9e 100644 --- a/src/ParametersPlugin/CMakeLists.txt +++ b/src/ParametersPlugin/CMakeLists.txt @@ -77,4 +77,5 @@ INSTALL(FILES ${QM_RESOURCES} DESTINATION ${SHAPER_INSTALL_QM_RESOURCES}) ADD_UNIT_TESTS(TestParameterCreation.py TestParameterRename.py TestParameterChangeValue.py + Test1806.py ) diff --git a/src/ParametersPlugin/Test/Test1806.py b/src/ParametersPlugin/Test/Test1806.py new file mode 100644 index 000000000..096a9657b --- /dev/null +++ b/src/ParametersPlugin/Test/Test1806.py @@ -0,0 +1,51 @@ +""" + Test1806.py + Unit test for testing the expression evaluation even no parameters are created + +""" +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * + +__updated__ = "2016-11-23" + +aSession = ModelAPI_Session.get() +aPartSet = aSession.moduleDocument() + +#========================================================================= +# Create a part +#========================================================================= +aSession.startOperation() +aPartFeature = aPartSet.addFeature("Part") +aSession.finishOperation() + +aPart = aSession.activeDocument() +#========================================================================= +# Create a sketch with a line and length +#========================================================================= +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +aXOYPlane = objectToResult(aPartSet.objectByName("Construction", "XOY")) +aSketchFeature.selection("External").setValue(aXOYPlane, None) +# Create lines +aLine = aSketchFeature.addFeature("SketchLine") +aStart = geomDataAPI_Point2D(aLine.attribute("StartPoint")) +aStart.setValue(0, 0) +anEnd = geomDataAPI_Point2D(aLine.attribute("EndPoint")) +anEnd.setValue(200, 0) + +aDistance = aSketchFeature.addFeature("SketchConstraintDistance") +aDistance.refattr("ConstraintEntityA").setAttr(aStart) +aDistance.refattr("ConstraintEntityB").setAttr(anEnd) +aDistance.real("ConstraintValue").setText("25/2") + +aSession.finishOperation() + +assert(aDistance.real("ConstraintValue").value() == 12.5) +#========================================================================= +# End of test +#========================================================================= +import model +assert(model.checkPythonDump()) -- 2.39.2