2024-04-27 04:31:19 +00:00
|
|
|
"""
|
2024-04-27 05:20:29 +00:00
|
|
|
Tests for gridfinity-rebuilt-holes.scad
|
2024-04-27 04:31:19 +00:00
|
|
|
@Copyright Arthur Moore 2024 MIT License
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from openscad_runner import *
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
2024-04-27 05:20:29 +00:00
|
|
|
class TestHoleCutouts(unittest.TestCase):
|
2024-04-27 04:31:19 +00:00
|
|
|
"""
|
2024-04-27 05:20:29 +00:00
|
|
|
Test Hole Cutouts. The negatives used with `difference()` to create a hole.
|
|
|
|
|
2024-04-27 04:31:19 +00:00
|
|
|
Currently only makes sure code runs, and outputs pictures for manual verification.
|
|
|
|
"""
|
|
|
|
|
2024-04-27 05:20:29 +00:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
cls.scad_runner = OpenScadRunner(Path('../gridfinity-rebuilt-holes.scad'))
|
|
|
|
cls.scad_runner.image_folder_base = Path('../images/hole_cutouts/')
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_refined_hole(self):
|
|
|
|
"""
|
|
|
|
refined_hole() is special, since top_angle_camera is not appropriate for it.
|
|
|
|
"""
|
|
|
|
camera_args = CameraArguments(Vec3(0,0,0),Vec3(225,0,225),50)
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=true, magnet_hole=false, screw_hole=false, crush_ribs=false, chamfer=false, supportless=false)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(camera_args, test_args, Path('refined_hole.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_plain_magnet_hole(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=false, crush_ribs=false, chamfer=false, supportless=false)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('magnet_hole.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_plain_screw_hole(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=false, screw_hole=true, crush_ribs=false, chamfer=false, supportless=false)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('screw_hole.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_magnet_and_screw_hole(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=true, crush_ribs=false, chamfer=false, supportless=false)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('magnet_and_screw_hole.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_chamfered_magnet_hole(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=false, crush_ribs=false, chamfer=true, supportless=false)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('chamfered_magnet_hole.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_magnet_hole_crush_ribs(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=false, crush_ribs=true, chamfer=false, supportless=false)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('magnet_hole_crush_ribs.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_magnet_hole_supportless(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=false, crush_ribs=false, chamfer=false, supportless=true)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('magnet_hole_supportless.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_magnet_and_screw_hole_supportless(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=true, crush_ribs=false, chamfer=false, supportless=true)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('magnet_and_screw_hole_supportless.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
def test_all_hole_options(self):
|
|
|
|
test_args = set_variable_argument('test_options',
|
|
|
|
'bundle_hole_options(refined_hole=false, magnet_hole=true, screw_hole=true, crush_ribs=true, chamfer=true, supportless=true)')
|
2024-04-27 05:20:29 +00:00
|
|
|
self.scad_runner.create_image(self.scad_runner.TOP_ANGLE_CAMERA,
|
|
|
|
test_args, Path('all_hole_options.png'))
|
2024-04-27 04:31:19 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|