test: add coverage for Total Stock Summary report

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nabin Hait
2026-06-26 10:18:57 +05:30
parent 6d035274d7
commit 3c749ec785

View File

@@ -0,0 +1,34 @@
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
import frappe
from erpnext.stock.doctype.item.test_item import make_item
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
from erpnext.stock.report.total_stock_summary.total_stock_summary import execute
from erpnext.tests.utils import ERPNextTestSuite
class TestTotalStockSummary(ERPNextTestSuite):
def run_report(self, **extra):
filters = frappe._dict({"company": "_Test Company", "group_by": "Warehouse", **extra})
return execute(filters)[1]
def test_warehouse_wise_quantity(self):
item = make_item().name
warehouse = create_warehouse("_Test TSS Warehouse")
make_stock_entry(item_code=item, to_warehouse=warehouse, qty=10, rate=100)
# rows are (warehouse, item_code, description, actual_qty)
row = next(r for r in self.run_report() if r[0] == warehouse and r[1] == item)
self.assertEqual(row[3], 10)
def test_only_non_zero_bins_are_listed(self):
item = make_item().name
warehouse = create_warehouse("_Test TSS Empty Warehouse")
# receive then issue everything -> bin actual_qty back to zero
make_stock_entry(item_code=item, to_warehouse=warehouse, qty=5, rate=100)
make_stock_entry(item_code=item, from_warehouse=warehouse, qty=5)
self.assertFalse([r for r in self.run_report() if r[0] == warehouse and r[1] == item])