Cosplay/nhf/test.py

46 lines
1.4 KiB
Python
Raw Normal View History

2024-06-20 23:29:18 -07:00
import unittest
2024-06-24 11:13:11 -07:00
import cadquery as Cq
2024-06-20 23:29:18 -07:00
import nhf.joints
2024-06-25 06:11:48 -07:00
import nhf.handle
2024-06-26 08:28:25 -07:00
import nhf.metric_threads as NMt
2024-06-20 23:29:18 -07:00
class TestJoints(unittest.TestCase):
2024-06-24 11:13:11 -07:00
def test_joint_hirth(self):
j = nhf.joints.hirth_joint()
2024-06-26 06:44:02 -07:00
self.assertIsInstance(
j.val().solids(), Cq.Solid,
msg="Hirth joint must be in one piece")
2024-06-20 23:29:18 -07:00
def test_joints_hirth_assembly(self):
nhf.joints.hirth_assembly()
def test_joints_comma_assembly(self):
nhf.joints.comma_assembly()
2024-06-25 06:11:48 -07:00
class TestHandle(unittest.TestCase):
def test_handle_assembly(self):
h = nhf.handle.Handle()
2024-06-26 08:28:25 -07:00
assembly = h.connector_insertion_assembly()
bbox = assembly.toCompound().BoundingBox()
self.assertAlmostEqual(bbox.xlen, h.diam)
self.assertAlmostEqual(bbox.ylen, h.diam)
assembly = h.connector_one_side_insertion_assembly()
bbox = assembly.toCompound().BoundingBox()
self.assertAlmostEqual(bbox.xlen, h.diam)
self.assertAlmostEqual(bbox.ylen, h.diam)
class TestMetricThreads(unittest.TestCase):
def test_major_radius(self):
major = 3.0
t = NMt.external_metric_thread(major, 0.5, 4.0, z_start= -0.85, top_lead_in=True)
bbox = t.val().BoundingBox()
self.assertAlmostEqual(bbox.xlen, major, places=3)
self.assertAlmostEqual(bbox.ylen, major, places=3)
2024-06-25 06:11:48 -07:00
2024-06-20 23:29:18 -07:00
if __name__ == '__main__':
unittest.main()