mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-12-22 14:53:25 +00:00
Add tests baseplate hole options
This commit is contained in:
parent
a4807fd3ab
commit
6f4e3b590e
3 changed files with 106 additions and 1 deletions
22
tests/gridfinity-rebuilt-baseplate.json
Normal file
22
tests/gridfinity-rebuilt-baseplate.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"fileFormatVersion": "1",
|
||||||
|
"parameterSets": {
|
||||||
|
"Default": {
|
||||||
|
"$fa": "8",
|
||||||
|
"$fs": "0.25",
|
||||||
|
"d_screw": "3.3500000000000001",
|
||||||
|
"d_screw_head": "5",
|
||||||
|
"distancex": "0",
|
||||||
|
"distancey": "0",
|
||||||
|
"enable_magnet": "true",
|
||||||
|
"fitx": "0",
|
||||||
|
"fity": "0",
|
||||||
|
"gridx": "1",
|
||||||
|
"gridy": "1",
|
||||||
|
"n_screws": "1",
|
||||||
|
"screw_spacing": "0.5",
|
||||||
|
"style_hole": "1",
|
||||||
|
"style_plate": "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
tests/test_baseplate.py
Normal file
83
tests/test_baseplate.py
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
"""
|
||||||
|
Tests for gridfinity-rebuilt-baseplate.scad
|
||||||
|
@Copyright Arthur Moore 2024 MIT License
|
||||||
|
"""
|
||||||
|
|
||||||
|
import dataclasses
|
||||||
|
import json
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
|
from openscad_runner import *
|
||||||
|
|
||||||
|
class TestBasePlateHoles(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test creating a single base in "gridfinity-spiral-vase.scad"
|
||||||
|
|
||||||
|
Currently only makes sure code runs, and outputs pictures for manual verification.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
parameter_file_path = Path("gridfinity-rebuilt-baseplate.json")
|
||||||
|
parameter_file_data = ParameterFile.from_json(parameter_file_path.read_text())
|
||||||
|
cls.default_parameters = parameter_file_data.parameterSets["Default"]
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.scad_runner = OpenScadRunner(Path('../gridfinity-rebuilt-baseplate.scad'))
|
||||||
|
self.scad_runner.image_folder_base = Path('../images/baseplate/')
|
||||||
|
self.scad_runner.parameters = self.default_parameters.copy()
|
||||||
|
self.scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||||
|
|
||||||
|
def test_no_holes(self):
|
||||||
|
vars = self.scad_runner.parameters
|
||||||
|
vars["enable_magnet"] = False
|
||||||
|
vars["style_hole"] = 0
|
||||||
|
self.scad_runner.create_image([], Path('no_holes_bottom.png'))
|
||||||
|
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||||
|
self.scad_runner.create_image([], Path('no_holes_top.png'))
|
||||||
|
|
||||||
|
def test_only_magnet_holes(self):
|
||||||
|
vars = self.scad_runner.parameters
|
||||||
|
vars["enable_magnet"] = True
|
||||||
|
vars["style_hole"] = 0
|
||||||
|
self.scad_runner.create_image([], Path('only_magnet_holes_bottom.png'))
|
||||||
|
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||||
|
self.scad_runner.create_image([], Path('only_magnet_holes_top.png'))
|
||||||
|
|
||||||
|
def test_only_countersunk_screw_holes(self):
|
||||||
|
vars = self.scad_runner.parameters
|
||||||
|
vars["enable_magnet"] = False
|
||||||
|
vars["style_hole"] = 1
|
||||||
|
self.scad_runner.create_image([], Path('only_countersunk_screw_holes_bottom.png'))
|
||||||
|
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||||
|
self.scad_runner.create_image([], Path('only_countersunk_screw_holes_top.png'))
|
||||||
|
|
||||||
|
def test_only_counterbored_screw_holes(self):
|
||||||
|
vars = self.scad_runner.parameters
|
||||||
|
vars["enable_magnet"] = False
|
||||||
|
vars["style_hole"] = 2
|
||||||
|
self.scad_runner.create_image([], Path('only_counterbored_screw_holes_bottom.png'))
|
||||||
|
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||||
|
self.scad_runner.create_image([], Path('only_counterbored_screw_holes_top.png'))
|
||||||
|
|
||||||
|
def test_magnet_and_countersunk_screw_holes(self):
|
||||||
|
vars = self.scad_runner.parameters
|
||||||
|
vars["enable_magnet"] = True
|
||||||
|
vars["style_hole"] = 1
|
||||||
|
self.scad_runner.create_image([], Path('magnet_and_countersunk_screw_holes_bottom.png'))
|
||||||
|
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||||
|
self.scad_runner.create_image([], Path('magnet_and_countersunk_screw_holes_top.png'))
|
||||||
|
|
||||||
|
def test_magnet_and_counterbored_screw_holes(self):
|
||||||
|
vars = self.scad_runner.parameters
|
||||||
|
vars["enable_magnet"] = True
|
||||||
|
vars["style_hole"] = 2
|
||||||
|
self.scad_runner.create_image([], Path('magnet_and_counterbored_screw_holes_bottom.png'))
|
||||||
|
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||||
|
self.scad_runner.create_image([], Path('magnet_and_counterbored_screw_holes_top.png'))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Tests for gridfinity-rebuilt-bins.scad
|
Tests for gridfinity-spiral-vase.scad
|
||||||
@Copyright Arthur Moore 2024 MIT License
|
@Copyright Arthur Moore 2024 MIT License
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue