From ba29323e116e525b898e0e685511c08118e2cf2d Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 12 Apr 2022 12:51:40 +0530 Subject: [PATCH] test: increase assertions to cover all cases --- erpnext/stock/report/stock_balance/stock_balance.py | 2 +- .../stock/report/stock_balance/test_stock_balance.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index 7fa417ac31..e5ea8e0612 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -387,7 +387,7 @@ def get_items(filters: StockBalanceFilter): if brand := filters.get("brand"): item_filters["brand"] = brand - return frappe.get_all("Item", filters=item_filters, pluck="name", order_by=None, debug=1) + return frappe.get_all("Item", filters=item_filters, pluck="name", order_by=None) def get_item_details(items, sle, filters: StockBalanceFilter): diff --git a/erpnext/stock/report/stock_balance/test_stock_balance.py b/erpnext/stock/report/stock_balance/test_stock_balance.py index 9130e8d1a4..09054fb972 100644 --- a/erpnext/stock/report/stock_balance/test_stock_balance.py +++ b/erpnext/stock/report/stock_balance/test_stock_balance.py @@ -71,14 +71,16 @@ class TestStockBalance(FrappeTestCase): # value invariant self.assertAlmostEqual(row.bal_val, row.opening_val + row.in_val - row.out_val, msg) - # valuation rate - self.assertAlmostEqual(row.val_rate, row.bal_val / row.bal_qty, 3, msg) - # check against SLE last_sle = item_wh_stock[(row.item_code, row.warehouse)] self.assertAlmostEqual(row.bal_qty, last_sle.qty_after_transaction, 3) self.assertAlmostEqual(row.bal_val, last_sle.stock_value, 3) + # valuation rate + if not row.bal_qty: + continue + self.assertAlmostEqual(row.val_rate, row.bal_val / row.bal_qty, 3, msg) + # ----------- tests def test_basic_stock_balance(self): @@ -133,6 +135,7 @@ class TestStockBalance(FrappeTestCase): rows = stock_balance(self.filters.update({"include_uom": "Box"})) self.assertEqual(rows[0].bal_qty_alt, 1) + self.assertInvariants(rows) def test_item_group(self): self.filters.pop("item_code", None) @@ -167,3 +170,4 @@ class TestStockBalance(FrappeTestCase): self.filters.update({"show_variant_attributes": 1, "item_code": variant.name}) ) self.assertPartialDictEq(attributes, rows[0]) + self.assertInvariants(rows)