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
This commit is contained in:
Nabin Hait
2026-06-22 13:00:59 +05:30
parent 26d0821c93
commit ef81caeb3d
3 changed files with 6 additions and 3 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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()