From a95f043b1e87fb51e4c71f99eaab681440847cde Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 27 Dec 2017 14:39:11 +0300 Subject: [PATCH] Extend unit tests for Vertex, Edge, Wire, Face and Shell features --- src/BuildPlugin/Test/TestEdge.py | 29 +++++++++++++++++++++++++++ src/BuildPlugin/Test/TestFace.py | 32 ++++++++++++++++++++++++++++++ src/BuildPlugin/Test/TestShell.py | 17 ++++++++++++++++ src/BuildPlugin/Test/TestVertex.py | 25 +++++++++++++++++++++++ src/BuildPlugin/Test/TestWire.py | 32 ++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+) diff --git a/src/BuildPlugin/Test/TestEdge.py b/src/BuildPlugin/Test/TestEdge.py index c64cae8e0..06c653dfb 100644 --- a/src/BuildPlugin/Test/TestEdge.py +++ b/src/BuildPlugin/Test/TestEdge.py @@ -111,5 +111,34 @@ aSession.finishOperation() # Test results assert (len(anEdgeFeature2.results()) == 12) +# Check Edge feature failed on incorrect input +aSession.startOperation() +anEdgeFeature3 = aPart.addFeature("Edge") +aBaseObjectsList = anEdgeFeature3.selectionList("base_objects") +aBaseObjectsList.append(aSketchResult, None) +aSession.finishOperation() +assert (len(anEdgeFeature3.results()) == 0) + +aSession.startOperation() +aBaseObjectsList.clear() +aShapeExplorer = GeomAPI_ShapeExplorer(aBoxShape, GeomAPI_Shape.VERTEX) +aShape = aShapeExplorer.current() +aBaseObjectsList.append(aBoxResult, aShape) +aSession.finishOperation() +assert (len(anEdgeFeature3.results()) == 0) + +aSession.startOperation() +aBaseObjectsList.clear() +aShapeExplorer = GeomAPI_ShapeExplorer(aBoxShape, GeomAPI_Shape.FACE) +aShape = aShapeExplorer.current() +aBaseObjectsList.append(aBoxResult, aShape) +aSession.finishOperation() +assert (len(anEdgeFeature3.results()) == 0) + +# remove failed feature +aSession.startOperation() +aPart.removeFeature(anEdgeFeature3) +aSession.finishOperation() + from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/TestFace.py b/src/BuildPlugin/Test/TestFace.py index a88618c8f..a64a2f913 100644 --- a/src/BuildPlugin/Test/TestFace.py +++ b/src/BuildPlugin/Test/TestFace.py @@ -141,5 +141,37 @@ aSession.startOperation() aPart.removeFeature(aFaceFeature4) aSession.finishOperation() +# ============================================================================= +# Test 5. Check Face feature failed on incorrect input +# ============================================================================= + +aSession.startOperation() +aFaceFeature5 = aPart.addFeature("Face") +aBaseObjectsList = aFaceFeature5.selectionList("base_objects") +aBaseObjectsList.append(aCylinderResult, None) +aSession.finishOperation() +assert (len(aFaceFeature5.results()) == 0) + +aSession.startOperation() +aBaseObjectsList.clear() +aShapeExplorer = GeomAPI_ShapeExplorer(aCylinderShape, GeomAPI_Shape.VERTEX) +aShape = aShapeExplorer.current() +aBaseObjectsList.append(aCylinderResult, aShape) +aSession.finishOperation() +assert (len(aFaceFeature5.results()) == 0) + +aSession.startOperation() +aBaseObjectsList.clear() +aShapeExplorer = GeomAPI_ShapeExplorer(aFaceFeature.lastResult().shape(), GeomAPI_Shape.EDGE) +aShape = aShapeExplorer.current() +aBaseObjectsList.append(aFaceFeature.lastResult(), aShape) +aSession.finishOperation() +assert (len(aFaceFeature5.results()) == 0) + +# remove failed feature +aSession.startOperation() +aPart.removeFeature(aFaceFeature5) +aSession.finishOperation() + from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/TestShell.py b/src/BuildPlugin/Test/TestShell.py index 4b371b972..6253c1e0f 100644 --- a/src/BuildPlugin/Test/TestShell.py +++ b/src/BuildPlugin/Test/TestShell.py @@ -123,5 +123,22 @@ aSession.finishOperation() # Test results assert (len(aShellFeature2.results()) > 0) +# Check Shell feature failed on incorrect input +aShellResult = aShellFeature.firstResult() +aSession.startOperation() +aShellFeature3 = aPart.addFeature("Shell") +aBaseObjectsList = aShellFeature3.selectionList("base_objects") +aShapeExplorer = GeomAPI_ShapeExplorer(aShellResult.shape(), GeomAPI_Shape.EDGE) +while aShapeExplorer.more(): + aBaseObjectsList.append(aShellResult, aShapeExplorer.current()) + aShapeExplorer.next() +aSession.finishOperation() +assert (len(aShellFeature3.results()) == 0) + +# remove failed feature +aSession.startOperation() +aPart.removeFeature(aShellFeature3) +aSession.finishOperation() + from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/TestVertex.py b/src/BuildPlugin/Test/TestVertex.py index eefe6e165..ad1701728 100644 --- a/src/BuildPlugin/Test/TestVertex.py +++ b/src/BuildPlugin/Test/TestVertex.py @@ -76,5 +76,30 @@ aSession.finishOperation() # Test results assert (len(aVertexFeature.results()) == aNumOfPoints) +# Check Vertex feature failed on incorrect input +aSession.startOperation() +aVertexFeature2 = aPart.addFeature("Vertex") +aBaseObjectsList = aVertexFeature2.selectionList("base_objects") +aBaseObjectsList.append(aSketchResult, None) +aSession.finishOperation() +assert (len(aVertexFeature2.results()) == 0) + +aSession.startOperation() +aLine = aSketchFeature.addFeature("SketchLine") +geomDataAPI_Point2D(aLine.attribute("StartPoint")).setValue(0, 0) +geomDataAPI_Point2D(aLine.attribute("EndPoint")).setValue(100, 100) +aSession.finishOperation() +aSession.startOperation() +aBaseObjectsList.clear() +aBaseObjectsList.append(aSketchResult, aLine.lastResult().shape()) +aSession.finishOperation() +assert (len(aVertexFeature2.results()) == 0) + +# remove failed feature +aSession.startOperation() +aPart.removeFeature(aVertexFeature2) +aPart.setCurrentFeature(aVertexFeature, True) +aSession.finishOperation() + from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/TestWire.py b/src/BuildPlugin/Test/TestWire.py index 351a29017..25dd4ecb2 100644 --- a/src/BuildPlugin/Test/TestWire.py +++ b/src/BuildPlugin/Test/TestWire.py @@ -145,4 +145,36 @@ aSession.finishOperation() # Test results assert (len(aWireFeature2.results()) == 1) +# ============================================================================= +# Test 4. Check Wire feature failed on incorrect input +# ============================================================================= + +aSession.startOperation() +aWireFeature3 = aPart.addFeature("Wire") +aBaseObjectsList = aWireFeature3.selectionList("base_objects") +aBaseObjectsList.append(aSketchResult, None) +aSession.finishOperation() +assert (len(aWireFeature3.results()) == 0) + +aSession.startOperation() +aBaseObjectsList.clear() +aShapeExplorer = GeomAPI_ShapeExplorer(aBoxShape, GeomAPI_Shape.VERTEX) +aShape = aShapeExplorer.current() +aBaseObjectsList.append(aBoxResult, aShape) +aSession.finishOperation() +assert (len(aWireFeature3.results()) == 0) + +aSession.startOperation() +aBaseObjectsList.clear() +aShapeExplorer = GeomAPI_ShapeExplorer(aBoxShape, GeomAPI_Shape.FACE) +aShape = aShapeExplorer.current() +aBaseObjectsList.append(aBoxResult, aShape) +aSession.finishOperation() +assert (len(aWireFeature3.results()) == 0) + +# remove failed feature +aSession.startOperation() +aPart.removeFeature(aWireFeature3) +aSession.finishOperation() + assert(model.checkPythonDump()) -- 2.39.2