Files
willtools-demo/WillTools.extension/tests/test_lifter_capacity_parts_table.py
will 25592fa6c2
ci / test (push) Successful in 6m14s
WillTools 2026-09-09 -- clean snapshot of the development repo for review
History-free snapshot of the private development repository at 77a82eb.
Code, docs and the public catalogue only: no plant or job knowledge
layers, no client, job or producer names (tools/scrub.py clean against
the widened term list; a second word-level grep clean). The intro deck is
left out because its slide images cannot be checked for job drawings.
2026-09-09 08:35:15 -05:00

129 lines
5.7 KiB
Python

# -*- coding: utf-8 -*-
"""A plant's own tested parts chart (`lifting_anchors.parts`) rates a lifter
when `lifters.capacity_lb` has nothing: tension by the plant's chosen sling
angle, shear as printed when it is a real non-zero number -- or equal to
tension for a back-cast face lifter the chart's footnote names. A printed
zero that the footnote does not reach is NOT RATED, not a real zero (see
`lifter_capacity`'s 2026-09-04 docstring note), and falls through to the
catalogue, or to None naming why, exactly like a field the table never
mentioned at all."""
from vibe import knowledge
def _know(**over):
base = {
'lifting_anchors': {
'sling_angle_choice': 60,
'sling_angles_published': [60, 75],
'back_cast_shear_equals_tension': True,
'back_cast_shear_equals_tension_applies_to': ['ZZ8T634', 'ZZ4T512'],
'parts': {
'ZZ8T634': {'usage': 'back_stripping', 'clutch_tons': 8,
'tension_60_lb': 9270, 'tension_75_lb': 10340,
'shear_lb': 0},
'QQ846': {'usage': 'back_stripping', 'tension_60_lb': 3080,
'tension_75_lb': 3440, 'shear_lb': 0},
'EE12': {'usage': 'edge', 'tension_lb': 5000, 'shear_lb': 2500},
},
},
'handling': {'lifter_groups': {'face': {'families': ['ZZ', 'QQ']},
'edge_top': {'families': ['EE']}}},
}
base.update(over)
return base
FACE = 'ZZ8T634_LIFTING PIN ANCHOR'
def test_tension_resolves_from_the_parts_chart_at_the_chosen_angle():
cap, basis, why = knowledge.lifter_capacity(_know(), FACE)
assert (cap, basis) == (9270, 'plant_table'), why
assert 'lifting_anchors.parts' in why and '60' in why
def test_back_cast_face_lifter_shear_equals_tension():
cap, basis, why = knowledge.lifter_capacity(_know(), FACE, kind='shear')
assert (cap, basis) == (9270, 'plant_table'), why
assert 'back' in why
def test_footnote_does_not_reach_a_part_it_does_not_name():
"""QQ846 prints a bare Zero with no footnote marker -- NOT RATED here
(2026-09-04: a printed zero is never taken as a real rating on its own,
see `lifter_capacity`'s docstring), and this fixture has no catalogue
fallback for it either, so the answer is None with a why naming that."""
cap, basis, why = knowledge.lifter_capacity(_know(), 'QQ846_ANCHOR', kind='shear')
assert (cap, basis) == (None, None), why
assert 'QQ846' in why and 'catalogue alias' in why
def test_footnote_does_not_apply_to_an_edge_lifter():
"""Same fixture as the face-lifter footnote test above, but with the
family regrouped as EDGE -- `_is_face_lifter` now says no, so the
footnote does not fire even though the part is named in
`back_cast_shear_equals_tension_applies_to`, and (no catalogue in this
fixture) the answer stands down naming both layers tried."""
know = _know()
know['handling']['lifter_groups']['face']['families'] = ['QQ']
cap, basis, why = knowledge.lifter_capacity(know, FACE, kind='shear')
assert (cap, basis) == (None, None), why
assert 'catalogue alias' in why
def test_printed_zero_falls_through_to_the_catalogue_when_one_exists():
"""The other half of the fix: a printed/pinned zero is not a dead end
when the published catalogue DOES rate the part -- `basis` becomes
'catalogue' and `why` names both the plant table's silence and the
catalogue's number, never a bare 0 from the chart."""
know = _know()
know['lifters'] = {'catalogue_alias': {'QQ846': 'SAMPLE_INSERT'}}
know['catalogue'] = {'inserts': {'SAMPLE_INSERT': {'shear_load_lb': 4000,
'working_load_lb': 9000}}}
cap, basis, why = knowledge.lifter_capacity(know, 'QQ846_ANCHOR', kind='shear')
assert (cap, basis) == (4000, 'catalogue'), why
assert 'QQ846' in why and 'prints a published/pinned zero' in why
assert 'catalogue.inserts.SAMPLE_INSERT' in why
def test_forbidden_is_a_deliberate_zero_not_a_missing_rating():
"""`shear_lb: forbidden` (or `false`) is the plant stating outright that
this part may never be loaded that way -- a real, deliberate zero, and
it must come back as 0 even though a printed bare 0 no longer does."""
know = _know()
know['lifting_anchors']['parts']['QQ846']['shear_lb'] = 'forbidden'
cap, basis, why = knowledge.lifter_capacity(know, 'QQ846_ANCHOR', kind='shear')
assert (cap, basis) == (0, 'plant_table'), why
assert 'FORBIDDEN' in why and 'deliberate' in why
know2 = _know()
know2['lifting_anchors']['parts']['QQ846']['shear_lb'] = False
cap, basis, why = knowledge.lifter_capacity(know2, 'QQ846_ANCHOR', kind='shear')
assert (cap, basis) == (0, 'plant_table'), why
assert 'FORBIDDEN' in why
def test_plain_tension_and_shear_entries_read_as_stated():
assert knowledge.lifter_capacity(_know(), 'EE12_EDGE')[0] == 5000
assert knowledge.lifter_capacity(_know(), 'EE12_EDGE', kind='shear')[0] == 2500
def test_no_sling_angle_choice_stands_down():
know = _know()
know['lifting_anchors']['sling_angle_choice'] = None
cap, basis, why = knowledge.lifter_capacity(know, FACE)
assert cap is None and basis is None
assert 'sling' in why.lower()
def test_lifters_capacity_lb_still_wins_over_the_chart():
know = _know(lifters={'capacity_lb': {'ZZ8T634': 7000}})
cap, basis, why = knowledge.lifter_capacity(know, FACE)
assert (cap, basis) == (7000, 'direct'), why
def test_unknown_family_still_falls_through_to_the_catalogue_path():
cap, basis, why = knowledge.lifter_capacity(_know(), 'NOPE_THING')
assert cap is None and basis is None
assert 'catalogue' in why