From 8ba26427ddd0a43967170a5dfb8cf2dbe098a5be Mon Sep 17 00:00:00 2001 From: Andrey Epifancev Date: Sun, 8 Nov 2026 16:04:33 +0400 Subject: [PATCH] =?UTF-8?q?fix(tests):=20test=5Fform2=5Fahr=5Flimit=20?= =?UTF-8?q?=E2=80=94=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5=20plan.qN=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=B7=20KeyError=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5?= =?UTF-8?q?=20null-strip=20(AURORA-1897,=20#296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit После AURORA-1848 GET листа вырезает null-поля, поэтому у заголовка статьи без плана в квартале ключа plan.qN нет вовсе, и чтение «до» падало KeyError до проверки самой логики. Заменено на plan.get("qN") or 0. Продуктовый код не меняется: с правкой все 7 тестов зелёные на test (после PR #295). Co-Authored-By: Claude Opus 5.5 --- api/tests/integration/test_form2_ahr_limit.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/api/tests/integration/test_form2_ahr_limit.py b/api/tests/integration/test_form2_ahr_limit.py index 55812df..9fdb0e0 100644 --- a/api/tests/integration/test_form2_ahr_limit.py +++ b/api/tests/integration/test_form2_ahr_limit.py @@ -104,7 +104,7 @@ def test_annual_dms_limit_divided_by_four(client, admin_tokens, form2_id): # лимитные LEAF из сидовых данных). before = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 456 - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 rows = _patch_cell(client, admin_tokens, form2_id, "AHR_LIMIT", 24, "qty_q1", 10) row = _find_by_id(rows, 24) @@ -113,7 +113,7 @@ def test_annual_dms_limit_divided_by_four(client, admin_tokens, form2_id): after = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 456 - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 assert (after - before) == pytest.approx(69.645) @@ -124,7 +124,7 @@ def test_quarterly_limit_uses_amount_without_vat(client, admin_tokens, form2_id) # статьи — см. комментарий в test_annual_dms_limit_divided_by_four. before = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 150 - )["data"]["plan"]["q2"] or 0 + )["data"]["plan"].get("q2") or 0 rows = _patch_cell(client, admin_tokens, form2_id, "AHR_LIMIT", 3, "qty_q2", 1) row = _find_by_id(rows, 3) @@ -132,7 +132,7 @@ def test_quarterly_limit_uses_amount_without_vat(client, admin_tokens, form2_id) after = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 150 - )["data"]["plan"]["q2"] or 0 + )["data"]["plan"].get("q2") or 0 assert (after - before) == pytest.approx(2.0) @@ -144,7 +144,7 @@ def test_sim_card_without_vat_limit_backfilled_is_not_zero(client, admin_tokens, # статьи — см. комментарий в test_annual_dms_limit_divided_by_four. before = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 150 - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 rows = _patch_cell(client, admin_tokens, form2_id, "AHR_LIMIT", 7, "qty_q1", 20) row = _find_by_id(rows, 7) @@ -152,7 +152,7 @@ def test_sim_card_without_vat_limit_backfilled_is_not_zero(client, admin_tokens, after = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 150 - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 assert (after - before) == pytest.approx(7.5) @@ -165,7 +165,7 @@ def test_printers_annual_limit_without_name_lookup(client, admin_tokens, form2_i # комментарий в test_annual_dms_limit_divided_by_four. before = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 167 - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 rows = _patch_cell(client, admin_tokens, form2_id, "AHR_LIMIT", 13, "qty_q1", 5) row = _find_by_id(rows, 13) @@ -173,7 +173,7 @@ def test_printers_annual_limit_without_name_lookup(client, admin_tokens, form2_i after = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 167 - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 assert (after - before) == pytest.approx(6.471875) @@ -185,7 +185,7 @@ def test_quarterly_norm_unchanged_other_than_vat_source(client, admin_tokens, fo # статьи — см. комментарий в test_annual_dms_limit_divided_by_four. before = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 179 - )["data"]["plan"]["q3"] or 0 + )["data"]["plan"].get("q3") or 0 rows = _patch_cell(client, admin_tokens, form2_id, "AHR_LIMIT", 17, "qty_q3", 2) row = _find_by_id(rows, 17) @@ -193,7 +193,7 @@ def test_quarterly_norm_unchanged_other_than_vat_source(client, admin_tokens, fo after = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), 179 - )["data"]["plan"]["q3"] or 0 + )["data"]["plan"].get("q3") or 0 assert (after - before) == pytest.approx(7.5) @@ -232,7 +232,7 @@ def test_rent_plan_still_passed_through_without_division(client, admin_tokens, f # быть другие записи аренды из сидовых данных). before = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), AHR_RENT_PARENT_EXPENSE_ITEM - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 response = client.post( f"/api/v1/form/{form2_id}/sheet/AHR_RENT/line", @@ -253,5 +253,5 @@ def test_rent_plan_still_passed_through_without_division(client, admin_tokens, f after = _find_ahr_header_row( _get_sheet_rows(client, admin_tokens, form2_id, "AHR"), AHR_RENT_PARENT_EXPENSE_ITEM - )["data"]["plan"]["q1"] or 0 + )["data"]["plan"].get("q1") or 0 assert (after - before) == 100 -- 2.47.2