DFiP_Budget_planing/perf/tests/test_gen_grow.py
Andrey Epifancev 501be971e7 perf(gen): grow не падает на ответах листа без null-полей
form4_ids вычисляет vsp_ids и project_ids из строк FORM_4 через .get
с пропуском отсутствующих ключей, grow_form4_sheet использует её.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 21:58:39 +04:00

27 lines
993 B
Python

import pytest
from perfkit.gen.grow import form4_ids, rows_to_add, TARGETS
@pytest.mark.parametrize("cur,target,exp", [(31, 500, 469), (110, 300, 190), (500, 500, 0), (700, 500, 0), (0, 5, 5)])
def test_rows_to_add(cur, target, exp):
assert rows_to_add(cur, target) == exp
def test_targets_do_not_touch_small_pair_sheets():
# AHR_RENT и FORM_4/AHR остаются малыми (пара для @big)
assert ("FORM_2", "AHR_RENT") not in [(f, s) for f, s, _ in TARGETS]
assert ("FORM_4", "AHR") not in [(f, s) for f, s, _ in TARGETS]
def test_form4_ids_tolerates_absent_keys():
rows = [
{"row_type": "INPUT", "data": {"header": {"vsp_id": 3}}},
{"row_type": "INPUT", "data": {"header": {}}},
{"row_type": "INPUT", "data": {}},
{"row_type": "ITEM", "data": {"header": {"project_id": 11}}},
{"row_type": "ITEM", "data": {"header": {}}},
{"row_type": "ITEM", "data": {}},
]
assert form4_ids(rows) == ([3], [11])