You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MPT-17888: fix bidirectional field mapping for consecutive uppercase letters
Add _FIELD_NAME_MAPPINGS (MappingProxyType) in model.py for API fields
that contain two or more consecutive uppercase letters (PPx1, SPxM,
unitLP, totalGT, etc.). The generic camelCase<->snake_case regex cannot
round-trip these correctly, so an explicit lookup table is checked first
in both to_snake_case and to_camel_case.
Affected fields from OpenAPI spec:
- PP*/SP*/LP* price columns (PPx1→ppx1, SPxM→spxm, LPxY→lpxy, ...)
- unit+acronym fields (unitLP→unit_lp, unitPP→unit_pp, unitSP→unit_sp)
- total+acronym fields (totalGT→total_gt, totalPP→total_pp, ...)
PriceListItem model annotations updated to use the corrected names
(ppx1, spxm, lpx1, etc. instead of p_px1, s_px_m, l_px1, ...).
to_dict() round-trip now works correctly for all price columns.
Tests:
- Merged price_list_item price fixture into main fixture for full
round-trip test coverage
- Added parametrized tests for to_snake_case and to_camel_case with
consecutive-uppercase fields in tests/unit/models/test_model.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments