TestLayer.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from cura.Layer import Layer
  2. from unittest.mock import MagicMock
  3. def test_lineMeshVertexCount():
  4. layer = Layer(1)
  5. layer_polygon = MagicMock()
  6. layer_polygon.lineMeshVertexCount = MagicMock(return_value = 9001)
  7. layer.polygons.append(layer_polygon)
  8. assert layer.lineMeshVertexCount() == 9001
  9. def test_lineMeshElementCount():
  10. layer = Layer(1)
  11. layer_polygon = MagicMock()
  12. layer_polygon.lineMeshElementCount = MagicMock(return_value = 9001)
  13. layer.polygons.append(layer_polygon)
  14. assert layer.lineMeshElementCount() == 9001
  15. def test_getAndSet():
  16. layer = Layer(0)
  17. layer.setThickness(12)
  18. assert layer.thickness == 12
  19. layer.setHeight(0.1)
  20. assert layer.height == 0.1
  21. def test_elementCount():
  22. layer = Layer(1)
  23. layer_polygon = MagicMock()
  24. layer_polygon.lineMeshElementCount = MagicMock(return_value=9002)
  25. layer_polygon.lineMeshVertexCount = MagicMock(return_value=9001)
  26. layer_polygon.elementCount = 12
  27. layer.polygons.append(layer_polygon)
  28. assert layer.build(0, 0, [], [], [], [], [] ,[] , []) == (9001, 9002)
  29. assert layer.elementCount == 12