mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 07:58:38 +00:00
test: reuse BootStrapTestData master data to reduce runtime
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
import frappe
|
||||
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
|
||||
from erpnext.stock.report.purchase_receipt_trends.purchase_receipt_trends import execute
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
@@ -23,18 +22,25 @@ class TestPurchaseReceiptTrends(ERPNextTestSuite):
|
||||
filters.update(extra)
|
||||
return execute(filters)[1]
|
||||
|
||||
def get_item_totals(self, data, item):
|
||||
# Row layout for based_on="Item", Yearly, no group_by:
|
||||
# [item_code, item_name, currency, FY(Qty), FY(Amt), Total(Qty), Total(Amt)]
|
||||
row = next((r for r in data if r[0] == item), None)
|
||||
if row is None:
|
||||
return 0, 0
|
||||
return row[3], row[4]
|
||||
|
||||
def test_receipt_qty_in_trend(self):
|
||||
item = make_item(properties={"is_stock_item": 1, "is_purchase_item": 1}).name
|
||||
item = "_Test Item"
|
||||
|
||||
# The report sums ALL purchase receipts for the item in the fiscal year, so capture
|
||||
# any pre-existing committed baseline and assert only this receipt's contribution.
|
||||
base_qty, base_amt = self.get_item_totals(self.run_report(), item)
|
||||
|
||||
make_purchase_receipt(
|
||||
item_code=item, qty=10, rate=100, company="_Test Company", posting_date="2026-06-01"
|
||||
)
|
||||
|
||||
data = self.run_report()
|
||||
|
||||
# Row layout for based_on="Item", Yearly, no group_by:
|
||||
# [item_code, item_name, currency, FY(Qty), FY(Amt), Total(Qty), Total(Amt)]
|
||||
row = next(r for r in data if r[0] == item)
|
||||
self.assertEqual(row[3], 10) # fiscal-year qty
|
||||
self.assertEqual(row[4], 1000) # fiscal-year amount (10 * 100)
|
||||
self.assertEqual(row[5], 10) # Total(Qty)
|
||||
self.assertEqual(row[6], 1000) # Total(Amt)
|
||||
qty, amt = self.get_item_totals(self.run_report(), item)
|
||||
self.assertEqual(qty - base_qty, 10) # fiscal-year qty
|
||||
self.assertEqual(amt - base_amt, 1000) # fiscal-year amount (10 * 100)
|
||||
|
||||
Reference in New Issue
Block a user