From 19475faa5fd5096a40ff875e0d3dfaffbfb78eb7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 May 2019 16:16:14 +0200 Subject: [PATCH] Add a few more simple tests for convex hull decorator --- tests/TestConvexHullDecorator.py | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/TestConvexHullDecorator.py b/tests/TestConvexHullDecorator.py index 5ee616c03b..1c7ceca8da 100644 --- a/tests/TestConvexHullDecorator.py +++ b/tests/TestConvexHullDecorator.py @@ -2,6 +2,7 @@ from unittest.mock import patch, MagicMock import pytest +from UM.Math.Polygon import Polygon from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from cura.Scene.ConvexHullDecorator import ConvexHullDecorator @@ -42,11 +43,43 @@ def test_getConvexHullBoundaryNoNode(convex_hull_decorator): assert convex_hull_decorator.getConvexHullBoundary() is None +def test_getConvexHullHeadNoNode(convex_hull_decorator): + assert convex_hull_decorator.getConvexHullHead() is None + + +def test_getConvexHullHeadNotPrintingMesh(convex_hull_decorator): + node = SceneNode() + node.addDecorator(NonPrintingDecorator()) + with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)): + convex_hull_decorator.setNode(node) + assert convex_hull_decorator.getConvexHullHead() is None + + +def test_getConvexHullNoNode(convex_hull_decorator): + assert convex_hull_decorator.getConvexHull() is None + + def test_getConvexHeadFullNoNode(convex_hull_decorator): assert convex_hull_decorator.getConvexHullHeadFull() is None -def test_getConvexHulLBoundaryNotPrintingMesh(convex_hull_decorator): +def test_getConvexHullNotPrintingMesh(convex_hull_decorator): + node = SceneNode() + node.addDecorator(NonPrintingDecorator()) + with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)): + convex_hull_decorator.setNode(node) + assert convex_hull_decorator.getConvexHull() is None + + +def test_getConvexHullPrintingMesh(convex_hull_decorator): + node = SceneNode() + node.addDecorator(PrintingDecorator()) + with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)): + convex_hull_decorator.setNode(node) + convex_hull_decorator._compute2DConvexHull = MagicMock(return_value = Polygon.approximatedCircle(10)) + assert convex_hull_decorator.getConvexHull() == Polygon.approximatedCircle(10) + +def test_getConvexHullBoundaryNotPrintingMesh(convex_hull_decorator): node = SceneNode() node.addDecorator(NonPrintingDecorator()) with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)):