Skip to content

Commit

Permalink
Merge pull request #238 from EmperorArthur/folders
Browse files Browse the repository at this point in the history
Adjust Folder Structure & Update Tests
  • Loading branch information
EmperorArthur authored Oct 19, 2024
2 parents a9e2618 + 2216f76 commit 6ce0884
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 191 deletions.
9 changes: 5 additions & 4 deletions gridfinity-rebuilt-baseplate.scad
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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] */
Expand Down
5 changes: 3 additions & 2 deletions gridfinity-rebuilt-bins.scad
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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] */
Expand Down
7 changes: 5 additions & 2 deletions gridfinity-rebuilt-lite.scad
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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] */
Expand Down
6 changes: 4 additions & 2 deletions gridfinity-spiral-vase.scad
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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] */
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marks this as the root directory for all tests.
[tool.pytest.ini_options]
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===== //

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
122 changes: 59 additions & 63 deletions tests/test_baseplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,110 @@
@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'))
Loading

0 comments on commit 6ce0884

Please sign in to comment.