25592fa6c2
ci / test (push) Successful in 6m14s
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.
83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Stress Limits & Factors pre-fill: a plant's `panelanalysis.settings`
|
|
mapping wins, the generic code values fill what it leaves out."""
|
|
import pytest
|
|
|
|
from vibe import knowledge # noqa: F401 (registers the vibe stub)
|
|
from vibe import panelanalysisform as F
|
|
|
|
|
|
PLANT = {
|
|
'handling_tension_sqrt': 6,
|
|
'handling_comp_ratio': 0.6,
|
|
'inplace_tension_sqrt': 7.5,
|
|
'inplace_comp_ratio': 0.6,
|
|
'phi_flexure': 0.9,
|
|
'phi_shear': 0.75,
|
|
'dev_mult': 1.3,
|
|
'deflection_limit': 'L/150',
|
|
'second_order': 'P-Delta',
|
|
'cracking_assumption': 'Uncracked',
|
|
}
|
|
|
|
|
|
def test_numbers_come_back_as_short_strings():
|
|
out = F.settings_from_plant(PLANT)
|
|
assert out['handling_tension_sqrt'] == '6'
|
|
assert out['inplace_tension_sqrt'] == '7.5'
|
|
assert out['phi_flexure'] == '0.9'
|
|
assert out['dev_mult'] == '1.3'
|
|
assert out['deflection_limit'] == 'L/150'
|
|
|
|
|
|
def test_second_order_method_means_yes():
|
|
assert F.settings_from_plant({'second_order': 'P-Delta'})['second_order'] == 'Yes'
|
|
assert F.settings_from_plant({'second_order': 'no'})['second_order'] == 'No'
|
|
assert F.settings_from_plant({'second_order': False})['second_order'] == 'No'
|
|
|
|
|
|
def test_cracking_assumption_normalises():
|
|
assert F.settings_from_plant({'cracking_assumption': 'cracked'})['cracking_assumption'] == 'Cracked'
|
|
assert F.settings_from_plant({'cracking_assumption': 'UNCRACKED'})['cracking_assumption'] == 'Uncracked'
|
|
|
|
|
|
def test_missing_and_blank_keys_are_left_out():
|
|
out = F.settings_from_plant({'phi_shear': None, 'dev_mult': ' ', 'phi_flexure': 0.65})
|
|
assert out == {'phi_flexure': '0.65'}
|
|
|
|
|
|
def test_no_mapping_is_empty():
|
|
assert F.settings_from_plant(None) == {}
|
|
assert F.settings_from_plant('L/150') == {}
|
|
|
|
|
|
def test_every_settings_key_has_a_form_field():
|
|
keys = set(f['key'] for f in F.FIELDS)
|
|
for key in F.SETTINGS_KEYS:
|
|
assert key in keys
|
|
|
|
|
|
def test_prefill_fills_the_generic_defaults_when_the_plant_is_silent():
|
|
values = F.prefill({})
|
|
assert values['phi_flexure'] == '0.9'
|
|
assert values['phi_shear'] == '0.75'
|
|
assert values['inplace_tension_sqrt'] == '7.5'
|
|
# second_order default flipped 'No' -> 'Yes' (P-Delta on by default),
|
|
# owner ruling 2026-09-04.
|
|
assert values['second_order'] == 'Yes'
|
|
assert values['cracking_assumption'] == 'Uncracked'
|
|
# deflection_limit, since 2026-09-04, gets `pa_defaults`' Eriksson
|
|
# Settings-page seed ('L/150') rather than staying blank when the plant
|
|
# is silent -- a plant's own pin (see `test_prefill_lets_the_plant_value_win`
|
|
# below) still wins over it.
|
|
assert values.get('deflection_limit', '') == 'L/150'
|
|
|
|
|
|
def test_prefill_lets_the_plant_value_win():
|
|
reads = dict(F.settings_from_plant(PLANT))
|
|
values = F.prefill(reads)
|
|
assert values['handling_tension_sqrt'] == '6'
|
|
assert values['dev_mult'] == '1.3'
|
|
assert values['deflection_limit'] == 'L/150'
|
|
assert values['second_order'] == 'Yes'
|