WillTools 2026-09-09 -- clean snapshot of the development repo for review
ci / test (push) Successful in 6m18s
ci / test (push) Successful in 6m18s
History-free snapshot of the private development repository at cbe45c5 (2026-09-09). Code, docs and public catalogue only; no plant or job knowledge layers, no client or job names (tools/scrub.py clean). The intro deck is left out of this snapshot because its slide images could not be checked for job drawings.
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Tests for `vibe.pa_prefill.merge_model_reads` -- the pure merge rule the
|
||||
Panel Analysis button uses to fold `pa_supports.read_supports`,
|
||||
`pa_lifters.read_lifters`, and `pa_reinf.read_reinforcement_prefill`'s output
|
||||
into its running `reads` dict.
|
||||
|
||||
Runs on plain CPython via `tests/conftest.py`'s import trick; `pa_prefill`
|
||||
touches neither Revit nor any of the three modules above -- it only knows the
|
||||
merge RULE, not where the dicts came from.
|
||||
"""
|
||||
from vibe import pa_prefill
|
||||
|
||||
|
||||
# ---------------------------------------------------------- default rule
|
||||
|
||||
def test_blank_slot_is_filled_from_a_single_dict():
|
||||
reads = {}
|
||||
out = pa_prefill.merge_model_reads(reads, {'fc_psi': 5000})
|
||||
assert out is reads
|
||||
assert reads == {'fc_psi': 5000}
|
||||
|
||||
|
||||
def test_non_override_key_already_set_wins_over_the_new_read():
|
||||
reads = {'ps_count': 4}
|
||||
pa_prefill.merge_model_reads(reads, {'ps_count': 12})
|
||||
assert reads['ps_count'] == 4
|
||||
|
||||
|
||||
def test_non_override_key_blank_gets_filled():
|
||||
reads = {'ps_count': None}
|
||||
pa_prefill.merge_model_reads(reads, {'ps_count': 12})
|
||||
assert reads['ps_count'] == 12
|
||||
|
||||
|
||||
def test_key_absent_from_reads_gets_filled():
|
||||
reads = {}
|
||||
pa_prefill.merge_model_reads(reads, {'mesh': 'WWF 6x6 W1.4xW1.4'})
|
||||
assert reads['mesh'] == 'WWF 6x6 W1.4xW1.4'
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- None
|
||||
|
||||
def test_none_value_never_overwrites_an_existing_value():
|
||||
reads = {'mesh': 'existing'}
|
||||
pa_prefill.merge_model_reads(reads, {'mesh': None})
|
||||
assert reads['mesh'] == 'existing'
|
||||
|
||||
|
||||
def test_none_value_never_fills_a_blank():
|
||||
reads = {}
|
||||
pa_prefill.merge_model_reads(reads, {'mesh': None})
|
||||
assert 'mesh' not in reads
|
||||
|
||||
|
||||
def test_none_value_on_an_override_key_still_does_not_overwrite():
|
||||
reads = {'mild_as': 'PNL101, PNL102'}
|
||||
pa_prefill.merge_model_reads(reads, {'mild_as': None})
|
||||
assert reads['mild_as'] == 'PNL101, PNL102'
|
||||
|
||||
|
||||
# ------------------------------------------------------------ override keys
|
||||
|
||||
def test_override_key_wins_over_an_existing_non_blank_value():
|
||||
# mild_as: the old marks-list from `_assembly_reinforcement` is already
|
||||
# in `reads`; the new (bar size, type) summary must replace it, not lose
|
||||
# to "a value already read off the piece wins".
|
||||
reads = {'mild_as': 'PNL101, PNL102, PNL103'}
|
||||
pa_prefill.merge_model_reads(
|
||||
reads, {'mild_as': '52 x #4 (MC_17-04)'})
|
||||
assert reads['mild_as'] == '52 x #4 (MC_17-04)'
|
||||
|
||||
|
||||
def test_every_named_override_key_wins():
|
||||
for key in ('supports_ft', 'face_lifters', 'edge_lifters',
|
||||
'ps_rows', 'mild_as'):
|
||||
reads = {key: 'old'}
|
||||
pa_prefill.merge_model_reads(reads, {key: 'new'})
|
||||
assert reads[key] == 'new', key
|
||||
|
||||
|
||||
def test_override_key_fills_a_blank_slot_too():
|
||||
reads = {}
|
||||
pa_prefill.merge_model_reads(reads, {'supports_ft': '0.50, 12.60, 24.70'})
|
||||
assert reads['supports_ft'] == '0.50, 12.60, 24.70'
|
||||
|
||||
|
||||
# ------------------------------------------------------------- multi-part
|
||||
|
||||
def test_multiple_parts_merge_in_order_given():
|
||||
reads = {}
|
||||
supports = {'supports_ft': '0.50, 24.70', 'supports_basis': 'why 1'}
|
||||
lifters = {'face_lifters': '4.00 @ 0.10', 'lifters_basis': 'why 2'}
|
||||
reinf = {'ps_count': 4, 'ps_rows': '4 @ 2', 'reinf_basis': ['why 3']}
|
||||
pa_prefill.merge_model_reads(reads, (supports, lifters, reinf))
|
||||
assert reads['supports_ft'] == '0.50, 24.70'
|
||||
assert reads['supports_basis'] == 'why 1'
|
||||
assert reads['face_lifters'] == '4.00 @ 0.10'
|
||||
assert reads['lifters_basis'] == 'why 2'
|
||||
assert reads['ps_count'] == 4
|
||||
assert reads['ps_rows'] == '4 @ 2'
|
||||
assert reads['reinf_basis'] == ['why 3']
|
||||
|
||||
|
||||
def test_empty_and_none_parts_are_skipped_without_raising():
|
||||
reads = {'a': 1}
|
||||
pa_prefill.merge_model_reads(reads, ({}, None, {'b': 2}))
|
||||
assert reads == {'a': 1, 'b': 2}
|
||||
|
||||
|
||||
def test_no_parts_at_all_is_a_no_op():
|
||||
reads = {'a': 1}
|
||||
out = pa_prefill.merge_model_reads(reads, [])
|
||||
assert out == {'a': 1}
|
||||
out = pa_prefill.merge_model_reads(reads, None)
|
||||
assert out == {'a': 1}
|
||||
Reference in New Issue
Block a user