test: increase assertions to cover all cases
This commit is contained in:
parent
e278ee359a
commit
ba29323e11
@ -387,7 +387,7 @@ def get_items(filters: StockBalanceFilter):
|
|||||||
if brand := filters.get("brand"):
|
if brand := filters.get("brand"):
|
||||||
item_filters["brand"] = 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):
|
def get_item_details(items, sle, filters: StockBalanceFilter):
|
||||||
|
@ -71,14 +71,16 @@ class TestStockBalance(FrappeTestCase):
|
|||||||
# value invariant
|
# value invariant
|
||||||
self.assertAlmostEqual(row.bal_val, row.opening_val + row.in_val - row.out_val, msg)
|
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
|
# check against SLE
|
||||||
last_sle = item_wh_stock[(row.item_code, row.warehouse)]
|
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_qty, last_sle.qty_after_transaction, 3)
|
||||||
self.assertAlmostEqual(row.bal_val, last_sle.stock_value, 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
|
# ----------- tests
|
||||||
|
|
||||||
def test_basic_stock_balance(self):
|
def test_basic_stock_balance(self):
|
||||||
@ -133,6 +135,7 @@ class TestStockBalance(FrappeTestCase):
|
|||||||
|
|
||||||
rows = stock_balance(self.filters.update({"include_uom": "Box"}))
|
rows = stock_balance(self.filters.update({"include_uom": "Box"}))
|
||||||
self.assertEqual(rows[0].bal_qty_alt, 1)
|
self.assertEqual(rows[0].bal_qty_alt, 1)
|
||||||
|
self.assertInvariants(rows)
|
||||||
|
|
||||||
def test_item_group(self):
|
def test_item_group(self):
|
||||||
self.filters.pop("item_code", None)
|
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.filters.update({"show_variant_attributes": 1, "item_code": variant.name})
|
||||||
)
|
)
|
||||||
self.assertPartialDictEq(attributes, rows[0])
|
self.assertPartialDictEq(attributes, rows[0])
|
||||||
|
self.assertInvariants(rows)
|
||||||
|
Loading…
Reference in New Issue
Block a user