mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 20:05:56 +08:00
Added simple test for BuildVolume
This commit is contained in:
parent
54ffcc478c
commit
f85095f5d8
@ -165,16 +165,13 @@ class BuildVolume(SceneNode):
|
|||||||
active_extruder_changed.connect(self._updateDisallowedAreasAndRebuild)
|
active_extruder_changed.connect(self._updateDisallowedAreasAndRebuild)
|
||||||
|
|
||||||
def setWidth(self, width: float) -> None:
|
def setWidth(self, width: float) -> None:
|
||||||
if width is not None:
|
self._width = width
|
||||||
self._width = width
|
|
||||||
|
|
||||||
def setHeight(self, height: float) -> None:
|
def setHeight(self, height: float) -> None:
|
||||||
if height is not None:
|
self._height = height
|
||||||
self._height = height
|
|
||||||
|
|
||||||
def setDepth(self, depth: float) -> None:
|
def setDepth(self, depth: float) -> None:
|
||||||
if depth is not None:
|
self._depth = depth
|
||||||
self._depth = depth
|
|
||||||
|
|
||||||
def setShape(self, shape: str) -> None:
|
def setShape(self, shape: str) -> None:
|
||||||
if shape:
|
if shape:
|
||||||
|
27
tests/TestBuildVolume.py
Normal file
27
tests/TestBuildVolume.py
Normal file
@ -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
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user