From f85095f5d8cf1763775131719d544098f5b32930 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 May 2019 17:19:27 +0200 Subject: [PATCH] Added simple test for BuildVolume --- cura/BuildVolume.py | 9 +++------ tests/TestBuildVolume.py | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 tests/TestBuildVolume.py diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 038d0e9791..d822a9e1c9 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -165,16 +165,13 @@ class BuildVolume(SceneNode): active_extruder_changed.connect(self._updateDisallowedAreasAndRebuild) def setWidth(self, width: float) -> None: - if width is not None: - self._width = width + self._width = width def setHeight(self, height: float) -> None: - if height is not None: - self._height = height + self._height = height def setDepth(self, depth: float) -> None: - if depth is not None: - self._depth = depth + self._depth = depth def setShape(self, shape: str) -> None: if shape: diff --git a/tests/TestBuildVolume.py b/tests/TestBuildVolume.py new file mode 100644 index 0000000000..491c0b1b6f --- /dev/null +++ b/tests/TestBuildVolume.py @@ -0,0 +1,27 @@ +from unittest.mock import MagicMock, patch + +import pytest + +from cura.BuildVolume import BuildVolume + +@pytest.fixture +def build_volume(): + mocked_application = MagicMock() + mocked_platform = MagicMock(name="platform") + with patch("cura.BuildVolume.Platform", mocked_platform): + return BuildVolume(mocked_application) + + +def test_buildVolumeSetSizes(build_volume): + build_volume.setWidth(10) + assert build_volume.getDiagonalSize() == 10 + + build_volume.setWidth(0) + build_volume.setHeight(100) + assert build_volume.getDiagonalSize() == 100 + + build_volume.setHeight(0) + build_volume.setDepth(200) + assert build_volume.getDiagonalSize() == 200 + +