Adding fits
This commit is contained in:
1 parent
8185f1f8b3
commit
ab39191af5
19 files changed
+1253
-1
No files matched your search
@@ -0,0 +1,102 @@
|
||||
from app.models.attachment_point import AttachmentPoint
|
||||
from app.models.augmented_part import AugmentedPart
|
||||
from app.models.clamp_connection import ClampConnection
|
||||
from app.models.iso_thread import IsoThread
|
||||
from app.models.static_connection import StaticConnection
|
||||
from app.models.unc_thread import UncSeries, UncThread
|
||||
from app.services.fit_matching import attachment_points_match, parts_could_fit
|
||||
|
||||
|
||||
def _ap(id_, name_id, **conn):
|
||||
ap = AttachmentPoint(attachment_point_name_id=name_id, augmented_part_id=1)
|
||||
ap.id = id_
|
||||
for field, value in conn.items():
|
||||
setattr(ap, field, value)
|
||||
return ap
|
||||
|
||||
|
||||
def test_iso_thread_exact_match():
|
||||
a = _ap(1, 1, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.25))
|
||||
b = _ap(2, 2, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.25))
|
||||
assert attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_iso_thread_mismatched_dimensions():
|
||||
a = _ap(1, 1, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.25))
|
||||
b = _ap(2, 2, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.0))
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_same_label_never_matches_even_with_identical_threads():
|
||||
a = _ap(1, 1, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.25))
|
||||
b = _ap(2, 1, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.25))
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_unc_thread_exact_match():
|
||||
a = _ap(1, 1, unc_thread=UncThread(diameter_fraction="1/4", tpi=20, series=UncSeries.UNC))
|
||||
b = _ap(2, 2, unc_thread=UncThread(diameter_fraction="1/4", tpi=20, series=UncSeries.UNC))
|
||||
assert attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_unc_thread_series_mismatch():
|
||||
a = _ap(1, 1, unc_thread=UncThread(diameter_fraction="1/4", tpi=20, series=UncSeries.UNC))
|
||||
b = _ap(2, 2, unc_thread=UncThread(diameter_fraction="1/4", tpi=20, series=UncSeries.UNF))
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_iso_and_unc_never_match_each_other():
|
||||
a = _ap(1, 1, iso_thread=IsoThread(diameter_mm=8, pitch_mm=1.25))
|
||||
b = _ap(2, 2, unc_thread=UncThread(diameter_fraction="1/4", tpi=20, series=UncSeries.UNC))
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_static_within_clamp_range_mm():
|
||||
a = _ap(1, 1, static_connection=StaticConnection(od_mm=30, od_in=1.18))
|
||||
b = _ap(2, 2, clamp_connection=ClampConnection(min_mm=25, max_mm=35))
|
||||
assert attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_static_outside_clamp_range_mm():
|
||||
a = _ap(1, 1, static_connection=StaticConnection(od_mm=40, od_in=1.57))
|
||||
b = _ap(2, 2, clamp_connection=ClampConnection(min_mm=25, max_mm=35))
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_static_matches_clamp_defined_only_in_inches():
|
||||
a = _ap(1, 1, static_connection=StaticConnection(od_mm=30, od_in=1.1811))
|
||||
b = _ap(2, 2, clamp_connection=ClampConnection(min_in=1.0, max_in=1.5))
|
||||
assert attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_static_matches_clamp_with_only_a_minimum():
|
||||
a = _ap(1, 1, static_connection=StaticConnection(od_mm=40, od_in=1.57))
|
||||
b = _ap(2, 2, clamp_connection=ClampConnection(min_mm=25))
|
||||
assert attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_clamp_with_no_bounds_never_matches():
|
||||
a = _ap(1, 1, static_connection=StaticConnection(od_mm=30, od_in=1.18))
|
||||
b = _ap(2, 2, clamp_connection=ClampConnection())
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_order_of_static_and_clamp_does_not_matter():
|
||||
a = _ap(1, 1, clamp_connection=ClampConnection(min_mm=25, max_mm=35))
|
||||
b = _ap(2, 2, static_connection=StaticConnection(od_mm=30, od_in=1.18))
|
||||
assert attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_two_bare_attachment_points_never_match():
|
||||
a = _ap(1, 1)
|
||||
b = _ap(2, 2)
|
||||
assert not attachment_points_match(a, b)
|
||||
|
||||
|
||||
def test_parts_could_fit_requires_different_types_and_identity():
|
||||
a = AugmentedPart(id=1, part_type_id=1, description="a", colour_id=1, manufacturer_id=1)
|
||||
b = AugmentedPart(id=2, part_type_id=1, description="b", colour_id=1, manufacturer_id=1)
|
||||
c = AugmentedPart(id=3, part_type_id=2, description="c", colour_id=1, manufacturer_id=1)
|
||||
assert not parts_could_fit(a, b)
|
||||
assert parts_could_fit(a, c)
|
||||
assert not parts_could_fit(a, a)
|
||||
Reference in new issue
Block a user