TestPlatformMeshes.py 1014 B

12345678910111213141516171819202122232425262728293031
  1. import pytest
  2. import os
  3. import os.path
  4. __exclude_filenames = ["UltimakerRobot_support.stl"]
  5. def collecAllPlatformMeshes():
  6. result = []
  7. for root, directories, filenames in os.walk(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "resources", "meshes"))):
  8. for filename in filenames:
  9. if filename not in __exclude_filenames:
  10. result.append(os.path.join(root, filename))
  11. return result
  12. platform_mesh_filepaths = collecAllPlatformMeshes()
  13. MAX_MESH_FILE_SIZE = 1 * 1024 * 1024 # 1MB
  14. # Check if the platform meshes adhere to the maximum file size (1MB)
  15. @pytest.mark.parametrize("file_name", platform_mesh_filepaths)
  16. def test_validatePlatformMeshSizes(file_name):
  17. assert os.path.getsize(file_name) <= MAX_MESH_FILE_SIZE, \
  18. "Platform mesh {} should be less than {}KB. Current file size: {}KB.".format(
  19. file_name,
  20. round(MAX_MESH_FILE_SIZE / 1024),
  21. round(os.path.getsize(file_name) / 1024, 2)
  22. )