test: increase assertions to cover all cases

This commit is contained in:
Ankush Menat 2022-04-12 12:51:40 +05:30
parent e278ee359a
commit ba29323e11
2 changed files with 8 additions and 4 deletions

View File

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

View File

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