mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-12-21 22:33:26 +00:00
Merge pull request #238 from EmperorArthur/folders
Adjust Folder Structure & Update Tests
This commit is contained in:
commit
6ce08841d5
14 changed files with 202 additions and 191 deletions
|
@ -1,7 +1,3 @@
|
|||
include <gridfinity-rebuilt-utility.scad>
|
||||
include <standard.scad>
|
||||
use <gridfinity-rebuilt-holes.scad>
|
||||
|
||||
// ===== INFORMATION ===== //
|
||||
/*
|
||||
IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg
|
||||
|
@ -10,6 +6,11 @@ https://github.com/kennetek/gridfinity-rebuilt-openscad
|
|||
|
||||
*/
|
||||
|
||||
include <src/core/standard.scad>
|
||||
use <src/core/gridfinity-rebuilt-utility.scad>
|
||||
use <src/core/gridfinity-rebuilt-holes.scad>
|
||||
use <src/helpers/generic-helpers.scad>
|
||||
|
||||
// ===== PARAMETERS ===== //
|
||||
|
||||
/* [Setup Parameters] */
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
include <gridfinity-rebuilt-utility.scad>
|
||||
|
||||
// ===== INFORMATION ===== //
|
||||
/*
|
||||
IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg
|
||||
|
@ -26,6 +24,9 @@ https://github.com/kennetek/gridfinity-rebuilt-openscad
|
|||
|
||||
*/
|
||||
|
||||
use <src/core/gridfinity-rebuilt-utility.scad>
|
||||
use <src/core/gridfinity-rebuilt-holes.scad>
|
||||
|
||||
// ===== PARAMETERS ===== //
|
||||
|
||||
/* [Setup Parameters] */
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
include <gridfinity-rebuilt-utility.scad>
|
||||
|
||||
// ===== INFORMATION ===== //
|
||||
/*
|
||||
IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg
|
||||
|
@ -8,6 +6,11 @@ https://github.com/kennetek/gridfinity-rebuilt-openscad
|
|||
|
||||
*/
|
||||
|
||||
include <src/core/standard.scad>
|
||||
use <src/core/gridfinity-rebuilt-utility.scad>
|
||||
use <src/core/gridfinity-rebuilt-holes.scad>
|
||||
use <src/helpers/generic-helpers.scad>
|
||||
|
||||
// ===== PARAMETERS ===== //
|
||||
|
||||
/* [Setup Parameters] */
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
include <gridfinity-rebuilt-utility.scad>
|
||||
|
||||
// ===== INFORMATION ===== //
|
||||
/*
|
||||
IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg
|
||||
|
@ -8,6 +6,10 @@ https://github.com/kennetek/gridfinity-rebuilt-openscad
|
|||
|
||||
*/
|
||||
|
||||
include <src/core/standard.scad>
|
||||
use <src/core/gridfinity-rebuilt-utility.scad>
|
||||
use <src/helpers/generic-helpers.scad>
|
||||
|
||||
// ===== PARAMETERS ===== //
|
||||
|
||||
/* [Special Variables] */
|
||||
|
|
2
pyproject.toml
Normal file
2
pyproject.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Marks this as the root directory for all tests.
|
||||
[tool.pytest.ini_options]
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
include <standard.scad>
|
||||
use <generic-helpers.scad>
|
||||
use <../helpers/generic-helpers.scad>
|
||||
|
||||
/**
|
||||
* @brief Determines the number of fragments in a circle. Aka, Circle resolution.
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
include <standard.scad>
|
||||
use <generic-helpers.scad>
|
||||
use <gridfinity-rebuilt-holes.scad>
|
||||
use <external/threads-scad/threads.scad>
|
||||
use <../helpers/generic-helpers.scad>
|
||||
use <../external/threads-scad/threads.scad>
|
||||
|
||||
// ===== User Modules ===== //
|
||||
|
|
@ -3,114 +3,110 @@ 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
|
||||
import pytest
|
||||
|
||||
from openscad_runner import *
|
||||
|
||||
class TestBasePlateHoles(unittest.TestCase):
|
||||
@pytest.fixture(scope="class")
|
||||
def default_parameters(pytestconfig):
|
||||
parameter_file_path = pytestconfig.rootpath.joinpath("tests/gridfinity-rebuilt-baseplate.json")
|
||||
parameter_file_data = ParameterFile.from_json(parameter_file_path.read_text())
|
||||
return parameter_file_data.parameterSets["Default"]
|
||||
|
||||
@pytest.fixture
|
||||
def openscad_runner(pytestconfig, default_parameters) -> OpenScadRunner:
|
||||
scad_path = pytestconfig.rootpath.joinpath('gridfinity-rebuilt-baseplate.scad')
|
||||
scad_runner = OpenScadRunner(scad_path)
|
||||
scad_runner.image_folder_base = pytestconfig.rootpath.joinpath('images/baseplate/')
|
||||
scad_runner.parameters = default_parameters.copy()
|
||||
scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||
return scad_runner
|
||||
|
||||
class TestBasePlateHoles:
|
||||
"""
|
||||
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
|
||||
def test_no_holes(self, openscad_runner):
|
||||
vars = openscad_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'))
|
||||
openscad_runner.create_image([], Path('no_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('no_holes_top.png'))
|
||||
|
||||
def test_plain_magnet_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_plain_magnet_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["enable_magnet"] = True
|
||||
vars["style_hole"] = 0
|
||||
vars["chamfer_holes"] = False
|
||||
vars["crush_ribs"] = False
|
||||
self.scad_runner.create_image([], Path('magnet_holes_bottom.png'))
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
self.scad_runner.create_image([], Path('plain_magnet_holes_top.png'))
|
||||
openscad_runner.create_image([], Path('magnet_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('plain_magnet_holes_top.png'))
|
||||
|
||||
def test_chamfered_magnet_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_chamfered_magnet_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["enable_magnet"] = True
|
||||
vars["style_hole"] = 0
|
||||
vars["chamfer_holes"] = True
|
||||
vars["crush_ribs"] = False
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
self.scad_runner.create_image([], Path('chamfered_magnet_holes.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('chamfered_magnet_holes.png'))
|
||||
|
||||
def test_ribbed_magnet_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_ribbed_magnet_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["enable_magnet"] = True
|
||||
vars["style_hole"] = 0
|
||||
vars["chamfer_holes"] = False
|
||||
vars["crush_ribs"] = True
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
self.scad_runner.create_image([], Path('ribbed_magnet_holes.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('ribbed_magnet_holes.png'))
|
||||
|
||||
def test_chamfered_and_ribbed_magnet_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_chamfered_and_ribbed_magnet_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["enable_magnet"] = True
|
||||
vars["style_hole"] = 0
|
||||
vars["chamfer_holes"] = True
|
||||
vars["crush_ribs"] = True
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
self.scad_runner.create_image([], Path('chamfered_and_ribbed_magnet_holes.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('chamfered_and_ribbed_magnet_holes.png'))
|
||||
|
||||
def test_only_countersunk_screw_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_only_countersunk_screw_holes(self, openscad_runner):
|
||||
vars = openscad_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'))
|
||||
openscad_runner.create_image([], Path('only_countersunk_screw_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('only_countersunk_screw_holes_top.png'))
|
||||
|
||||
def test_only_counterbored_screw_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_only_counterbored_screw_holes(self, openscad_runner):
|
||||
vars = openscad_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'))
|
||||
openscad_runner.create_image([], Path('only_counterbored_screw_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('only_counterbored_screw_holes_top.png'))
|
||||
|
||||
def test_magnet_and_countersunk_screw_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_and_countersunk_screw_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["enable_magnet"] = True
|
||||
vars["chamfer_holes"] = False
|
||||
vars["crush_ribs"] = False
|
||||
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'))
|
||||
openscad_runner.create_image([], Path('magnet_and_countersunk_screw_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('magnet_and_countersunk_screw_holes_top.png'))
|
||||
|
||||
def test_magnet_and_counterbored_screw_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_and_counterbored_screw_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["enable_magnet"] = True
|
||||
vars["chamfer_holes"] = False
|
||||
vars["crush_ribs"] = False
|
||||
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()
|
||||
openscad_runner.create_image([], Path('magnet_and_counterbored_screw_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledTop)
|
||||
openscad_runner.create_image([], Path('magnet_and_counterbored_screw_holes_top.png'))
|
||||
|
|
|
@ -3,15 +3,27 @@ Tests for gridfinity-rebuilt-bins.scad
|
|||
@Copyright Arthur Moore 2024 MIT License
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tempfile import NamedTemporaryFile
|
||||
import pytest
|
||||
|
||||
from openscad_runner import *
|
||||
|
||||
class TestBinHoles(unittest.TestCase):
|
||||
@pytest.fixture(scope="class")
|
||||
def default_parameters(pytestconfig):
|
||||
parameter_file_path = pytestconfig.rootpath.joinpath("tests/gridfinity-rebuilt-bins.json")
|
||||
parameter_file_data = ParameterFile.from_json(parameter_file_path.read_text())
|
||||
return parameter_file_data.parameterSets["Default"]
|
||||
|
||||
@pytest.fixture
|
||||
def openscad_runner(pytestconfig, default_parameters) -> OpenScadRunner:
|
||||
scad_path = pytestconfig.rootpath.joinpath('gridfinity-rebuilt-bins.scad')
|
||||
scad_runner = OpenScadRunner(scad_path)
|
||||
scad_runner.image_folder_base = pytestconfig.rootpath.joinpath('images/base_hole_options/')
|
||||
scad_runner.parameters = default_parameters.copy()
|
||||
scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||
return scad_runner
|
||||
|
||||
class TestBinHoles:
|
||||
"""
|
||||
Test how a single base looks with holes cut out.
|
||||
|
||||
|
@ -24,127 +36,124 @@ class TestBinHoles(unittest.TestCase):
|
|||
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-bins.scad'))
|
||||
self.scad_runner.image_folder_base = Path('../images/base_hole_options/')
|
||||
self.scad_runner.parameters = self.default_parameters.copy()
|
||||
self.scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||
def setUp(self, openscad_runner):
|
||||
openscad_runner = OpenScadRunner(Path('../src/core/gridfinity-rebuilt-bins.scad'))
|
||||
openscad_runner.image_folder_base = Path('../images/base_hole_options/')
|
||||
openscad_runner.parameters = self.default_parameters.copy()
|
||||
openscad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||
|
||||
def test_no_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_no_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = False
|
||||
vars["screw_holes"] = False
|
||||
self.scad_runner.create_image([], Path('no_holes.png'))
|
||||
openscad_runner.create_image([], Path('no_holes.png'))
|
||||
|
||||
def test_only_corner_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_only_corner_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = True
|
||||
vars["magnet_holes"] = False
|
||||
vars["screw_holes"] = False
|
||||
vars["only_corners"] = True
|
||||
self.scad_runner.create_image([], Path('only_corner_holes.png'))
|
||||
openscad_runner.create_image([], Path('only_corner_holes.png'))
|
||||
|
||||
def test_refined_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_refined_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = True
|
||||
vars["magnet_holes"] = False
|
||||
vars["screw_holes"] = False
|
||||
self.scad_runner.create_image([], Path('refined_holes.png'))
|
||||
openscad_runner.create_image([], Path('refined_holes.png'))
|
||||
|
||||
def test_refined_and_screw_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_refined_and_screw_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = True
|
||||
vars["magnet_holes"] = False
|
||||
vars["screw_holes"] = True
|
||||
vars["printable_hole_top"] = False
|
||||
self.scad_runner.create_image([], Path('refined_and_screw_holes.png'))
|
||||
openscad_runner.create_image([], Path('refined_and_screw_holes.png'))
|
||||
|
||||
def test_screw_holes_plain(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_screw_holes_plain(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = False
|
||||
vars["screw_holes"] = True
|
||||
vars["printable_hole_top"] = False
|
||||
self.scad_runner.create_image([], Path('screw_holes_plain.png'))
|
||||
openscad_runner.create_image([], Path('screw_holes_plain.png'))
|
||||
|
||||
def test_screw_holes_printable(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_screw_holes_printable(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = False
|
||||
vars["screw_holes"] = True
|
||||
vars["printable_hole_top"] = True
|
||||
self.scad_runner.create_image([], Path('screw_holes_printable.png'))
|
||||
openscad_runner.create_image([], Path('screw_holes_printable.png'))
|
||||
|
||||
def test_magnet_holes_plain(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_holes_plain(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = False
|
||||
vars["crush_ribs"] = False
|
||||
vars["chamfer_holes"] = False
|
||||
vars["printable_hole_top"] = False
|
||||
self.scad_runner.create_image([], Path('magnet_holes_plain.png'))
|
||||
openscad_runner.create_image([], Path('magnet_holes_plain.png'))
|
||||
|
||||
def test_magnet_holes_chamfered(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_holes_chamfered(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = False
|
||||
vars["crush_ribs"] = False
|
||||
vars["chamfer_holes"] = True
|
||||
vars["printable_hole_top"] = False
|
||||
self.scad_runner.create_image([], Path('magnet_holes_chamfered.png'))
|
||||
openscad_runner.create_image([], Path('magnet_holes_chamfered.png'))
|
||||
|
||||
def test_magnet_holes_printable(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_holes_printable(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = False
|
||||
vars["crush_ribs"] = False
|
||||
vars["chamfer_holes"] = False
|
||||
vars["printable_hole_top"] = True
|
||||
self.scad_runner.create_image([], Path('magnet_holes_printable.png'))
|
||||
openscad_runner.create_image([], Path('magnet_holes_printable.png'))
|
||||
|
||||
def test_magnet_holes_with_crush_ribs(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_holes_with_crush_ribs(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = False
|
||||
vars["crush_ribs"] = True
|
||||
vars["chamfer_holes"] = False
|
||||
vars["printable_hole_top"] = False
|
||||
self.scad_runner.create_image([], Path('magnet_holes_with_crush_ribs.png'))
|
||||
openscad_runner.create_image([], Path('magnet_holes_with_crush_ribs.png'))
|
||||
|
||||
def test_magnet_and_screw_holes_plain(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_and_screw_holes_plain(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = True
|
||||
vars["crush_ribs"] = False
|
||||
vars["chamfer_holes"] = False
|
||||
vars["printable_hole_top"] = False
|
||||
self.scad_runner.create_image([], Path('magnet_and_screw_holes_plain.png'))
|
||||
openscad_runner.create_image([], Path('magnet_and_screw_holes_plain.png'))
|
||||
|
||||
def test_magnet_and_screw_holes_printable(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_and_screw_holes_printable(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = True
|
||||
vars["crush_ribs"] = False
|
||||
vars["chamfer_holes"] = False
|
||||
vars["printable_hole_top"] = True
|
||||
self.scad_runner.create_image([], Path('magnet_and_screw_holes_printable.png'))
|
||||
openscad_runner.create_image([], Path('magnet_and_screw_holes_printable.png'))
|
||||
|
||||
def test_magnet_and_screw_holes_all(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_magnet_and_screw_holes_all(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["refined_holes"] = False
|
||||
vars["magnet_holes"] = True
|
||||
vars["screw_holes"] = True
|
||||
vars["crush_ribs"] = True
|
||||
vars["chamfer_holes"] = True
|
||||
vars["printable_hole_top"] = True
|
||||
self.scad_runner.create_image([], Path('magnet_and_screw_holes_all.png'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
openscad_runner.create_image([], Path('magnet_and_screw_holes_all.png'))
|
||||
|
|
|
@ -4,75 +4,75 @@ Tests for gridfinity-rebuilt-holes.scad
|
|||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from openscad_runner import *
|
||||
import unittest
|
||||
|
||||
@pytest.fixture
|
||||
def openscad_runner(pytestconfig) -> OpenScadRunner:
|
||||
scad_path = pytestconfig.rootpath.joinpath('src/core/gridfinity-rebuilt-holes.scad')
|
||||
scad_runner = OpenScadRunner(scad_path)
|
||||
scad_runner.image_folder_base = pytestconfig.rootpath.joinpath('images/hole_cutouts/')
|
||||
scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledTop, 50)
|
||||
return scad_runner
|
||||
|
||||
class TestHoleCutouts(unittest.TestCase):
|
||||
class TestHoleCutouts:
|
||||
"""
|
||||
Test Hole Cutouts. The negatives used with `difference()` to create a hole.
|
||||
|
||||
Currently only makes sure code runs, and outputs pictures for manual verification.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.scad_runner = OpenScadRunner(Path('../gridfinity-rebuilt-holes.scad'))
|
||||
self.scad_runner.image_folder_base = Path('../images/hole_cutouts/')
|
||||
self.scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledTop, 50)
|
||||
|
||||
def test_refined_hole(self):
|
||||
def test_refined_hole(self, openscad_runner):
|
||||
"""
|
||||
refined_hole() is special, since top_angle_camera is not appropriate for it.
|
||||
"""
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.AngledBottom)
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.AngledBottom)
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('refined_hole.png'))
|
||||
openscad_runner.create_image(test_args, Path('refined_hole.png'))
|
||||
|
||||
def test_plain_magnet_hole(self):
|
||||
def test_plain_magnet_hole(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('magnet_hole.png'))
|
||||
openscad_runner.create_image(test_args, Path('magnet_hole.png'))
|
||||
|
||||
def test_plain_screw_hole(self):
|
||||
def test_plain_screw_hole(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('screw_hole.png'))
|
||||
openscad_runner.create_image(test_args, Path('screw_hole.png'))
|
||||
|
||||
def test_magnet_and_screw_hole(self):
|
||||
def test_magnet_and_screw_hole(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('magnet_and_screw_hole.png'))
|
||||
openscad_runner.create_image(test_args, Path('magnet_and_screw_hole.png'))
|
||||
|
||||
def test_chamfered_magnet_hole(self):
|
||||
def test_chamfered_magnet_hole(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('chamfered_magnet_hole.png'))
|
||||
openscad_runner.create_image(test_args, Path('chamfered_magnet_hole.png'))
|
||||
|
||||
def test_magnet_hole_crush_ribs(self):
|
||||
def test_magnet_hole_crush_ribs(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('magnet_hole_crush_ribs.png'))
|
||||
openscad_runner.create_image(test_args, Path('magnet_hole_crush_ribs.png'))
|
||||
|
||||
def test_magnet_hole_supportless(self):
|
||||
def test_magnet_hole_supportless(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('magnet_hole_supportless.png'))
|
||||
openscad_runner.create_image(test_args, Path('magnet_hole_supportless.png'))
|
||||
|
||||
def test_magnet_and_screw_hole_supportless(self):
|
||||
def test_magnet_and_screw_hole_supportless(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('magnet_and_screw_hole_supportless.png'))
|
||||
openscad_runner.create_image(test_args, Path('magnet_and_screw_hole_supportless.png'))
|
||||
|
||||
def test_all_hole_options(self):
|
||||
def test_all_hole_options(self, openscad_runner):
|
||||
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)')
|
||||
self.scad_runner.create_image(test_args, Path('all_hole_options.png'))
|
||||
openscad_runner.create_image(test_args, Path('all_hole_options.png'))
|
||||
|
||||
def test_no_hole(self):
|
||||
def test_no_hole(self, openscad_runner):
|
||||
test_args = set_variable_argument('test_options',
|
||||
'bundle_hole_options(refined_hole=false, magnet_hole=false, screw_hole=false, crush_ribs=true, chamfer=true, supportless=true)')
|
||||
self.scad_runner.create_image(test_args, Path('no_hole.png'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
openscad_runner.create_image(test_args, Path('no_hole.png'))
|
||||
|
|
|
@ -3,48 +3,45 @@ Tests for gridfinity-spiral-vase.scad
|
|||
@Copyright Arthur Moore 2024 MIT License
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tempfile import NamedTemporaryFile
|
||||
import pytest
|
||||
|
||||
from openscad_runner import *
|
||||
|
||||
class TestSpiralVaseBase(unittest.TestCase):
|
||||
@pytest.fixture(scope="class")
|
||||
def default_parameters(pytestconfig):
|
||||
parameter_file_path = pytestconfig.rootpath.joinpath("tests/gridfinity-spiral-vase.json")
|
||||
parameter_file_data = ParameterFile.from_json(parameter_file_path.read_text())
|
||||
return parameter_file_data.parameterSets["Default"]
|
||||
|
||||
@pytest.fixture
|
||||
def openscad_runner(pytestconfig, default_parameters) -> OpenScadRunner:
|
||||
scad_path = pytestconfig.rootpath.joinpath('gridfinity-spiral-vase.scad')
|
||||
scad_runner = OpenScadRunner(scad_path)
|
||||
scad_runner.image_folder_base = pytestconfig.rootpath.joinpath('images/spiral_vase_base/')
|
||||
scad_runner.parameters = default_parameters.copy()
|
||||
scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||
return scad_runner
|
||||
|
||||
class TestSpiralVaseBase:
|
||||
"""
|
||||
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-spiral-vase.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-spiral-vase.scad'))
|
||||
self.scad_runner.image_folder_base = Path('../images/spiral_vase_base/')
|
||||
self.scad_runner.parameters = self.default_parameters.copy()
|
||||
self.scad_runner.parameters["type"] = 1 # Create a Base
|
||||
self.scad_runner.camera_arguments = CameraArguments(Vec3(0,0,0), CameraRotations.AngledBottom, 150)
|
||||
|
||||
def test_no_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_no_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["type"] = 1 # Create a Base
|
||||
vars["enable_holes"] = False
|
||||
self.scad_runner.create_image([], Path('no_holes_bottom.png'))
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.Top)
|
||||
self.scad_runner.create_image([], Path('no_holes_top.png'))
|
||||
openscad_runner.create_image([], Path('no_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.Top)
|
||||
openscad_runner.create_image([], Path('no_holes_top.png'))
|
||||
|
||||
def test_refined_holes(self):
|
||||
vars = self.scad_runner.parameters
|
||||
def test_holes(self, openscad_runner):
|
||||
vars = openscad_runner.parameters
|
||||
vars["type"] = 1 # Create a Base
|
||||
vars["enable_holes"] = True
|
||||
self.scad_runner.create_image([], Path('with_holes_bottom.png'))
|
||||
self.scad_runner.camera_arguments = self.scad_runner.camera_arguments.with_rotation(CameraRotations.Top)
|
||||
self.scad_runner.create_image([], Path('with_holes_top.png'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
openscad_runner.create_image([], Path('with_holes_bottom.png'))
|
||||
openscad_runner.camera_arguments = openscad_runner.camera_arguments.with_rotation(CameraRotations.Top)
|
||||
openscad_runner.create_image([], Path('with_holes_top.png'))
|
||||
|
|
Loading…
Reference in a new issue