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])