From ef81caeb3dd7ee815660b9eed6bd00c0e6566592 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 22 Jun 2026 13:00:59 +0530 Subject: [PATCH] test: address review feedback on Supplier Scorecard tests - assert cost-of-shipments against the PO base_amount instead of a hardcoded total, so it holds when conversion_rate != 1 - guard the idempotency test's fixed scorecard name against leftovers - clarify that the eval-statement zero/None substitution is a truthiness check --- .../doctype/supplier_scorecard/test_supplier_scorecard.py | 1 + .../test_supplier_scorecard_period.py | 3 ++- .../test_supplier_scorecard_variable.py | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py index fb55ff55505..f23940305e1 100644 --- a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py @@ -79,6 +79,7 @@ class TestSupplierScorecard(ERPNextTestSuite): supplier = create_test_supplier("_Test Supplier SC Idempotent") frappe.db.set_value("Supplier", supplier, "creation", add_days(nowdate(), -75)) + frappe.delete_doc_if_exists("Supplier Scorecard", supplier) doc = make_supplier_scorecard() doc.supplier = supplier doc.name = supplier diff --git a/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py b/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py index 5cbbc90d43f..ba8c7a1f70f 100644 --- a/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py +++ b/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py @@ -32,7 +32,8 @@ class TestSupplierScorecardPeriod(ERPNextTestSuite): {"variable_label": "B", "param_name": "b", "path": "get_total_workdays", "value": 0}, ] ) - # present value -> formatted; missing/zero value -> "0.0" + # get_eval_statement checks `if var.value:` (truthiness), so a falsy value - + # whether 0 or None - is substituted as "0.0", while a real value is formatted self.assertEqual(period.get_eval_statement("{a} + {b}"), "5.00 + 0.0") def test_period_score_is_weighted_sum_of_criteria(self): diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py index 175ddbc97a4..bf8e6d3e744 100644 --- a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py +++ b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py @@ -35,11 +35,12 @@ class TestSupplierScorecardVariable(ERPNextTestSuite): def test_total_cost_of_shipments_counts_only_in_period(self): supplier = create_scorecard_supplier() - create_scorecard_po(supplier, nowdate(), qty=10, rate=100) # in period -> 1000 + in_period_po = create_scorecard_po(supplier, nowdate(), qty=10, rate=100) create_scorecard_po(supplier, add_days(nowdate(), 60), qty=5, rate=100) # outside period scorecard = scorecard_for(supplier) - self.assertEqual(get_total_cost_of_shipments(scorecard), 1000) + # Compare against base_amount (not a hardcoded total) to stay correct if conversion_rate != 1 + self.assertEqual(get_total_cost_of_shipments(scorecard), in_period_po.items[0].base_amount) def test_on_time_and_delayed_shipments(self): supplier = create_scorecard_supplier()