55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import unittest
|
|
import cadquery as Cq
|
|
import nhf.joints
|
|
import nhf.handle
|
|
import nhf.metric_threads as NMt
|
|
from nhf.checks import binary_intersection
|
|
|
|
class TestJoints(unittest.TestCase):
|
|
|
|
def test_joint_hirth(self):
|
|
j = nhf.joints.hirth_joint()
|
|
self.assertIsInstance(
|
|
j.val().solids(), Cq.Solid,
|
|
msg="Hirth joint must be in one piece")
|
|
def test_joints_hirth_assembly(self):
|
|
assembly = nhf.joints.hirth_assembly()
|
|
isect = binary_intersection(assembly)
|
|
self.assertLess(isect.Volume(), 1e-6,
|
|
"Hirth joint assembly must not have intersection")
|
|
def test_joints_comma_assembly(self):
|
|
nhf.joints.comma_assembly()
|
|
def test_torsion_joint(self):
|
|
j = nhf.joints.TorsionJoint()
|
|
assembly = j.rider_track_assembly()
|
|
bbox = assembly.toCompound().BoundingBox()
|
|
self.assertAlmostEqual(bbox.zlen, j.total_height)
|
|
|
|
|
|
class TestHandle(unittest.TestCase):
|
|
|
|
def test_handle_assembly(self):
|
|
h = nhf.handle.Handle()
|
|
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)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|