mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-03 00:23:21 +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,11 +3,13 @@
|
|||||||
|
|
||||||
import frappe
|
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.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
from erpnext.stock.report.incorrect_serial_no_valuation.incorrect_serial_no_valuation import execute
|
from erpnext.stock.report.incorrect_serial_no_valuation.incorrect_serial_no_valuation import execute
|
||||||
from erpnext.tests.utils import ERPNextTestSuite
|
from erpnext.tests.utils import ERPNextTestSuite
|
||||||
|
|
||||||
|
SERIAL_ITEM = "_Test Serialized Item With Series"
|
||||||
|
WAREHOUSE = "Stores - _TC"
|
||||||
|
|
||||||
|
|
||||||
class TestIncorrectSerialNoValuation(ERPNextTestSuite):
|
class TestIncorrectSerialNoValuation(ERPNextTestSuite):
|
||||||
def run_report(self, **extra):
|
def run_report(self, **extra):
|
||||||
@@ -15,49 +17,36 @@ class TestIncorrectSerialNoValuation(ERPNextTestSuite):
|
|||||||
filters.update(extra)
|
filters.update(extra)
|
||||||
return execute(filters)[1]
|
return execute(filters)[1]
|
||||||
|
|
||||||
def make_serial_item(self):
|
|
||||||
return make_item(
|
|
||||||
properties={
|
|
||||||
"is_stock_item": 1,
|
|
||||||
"has_serial_no": 1,
|
|
||||||
"serial_no_series": "ISV-.#####",
|
|
||||||
}
|
|
||||||
).name
|
|
||||||
|
|
||||||
def test_healthy_serial_item_not_flagged(self):
|
def test_healthy_serial_item_not_flagged(self):
|
||||||
item = self.make_serial_item()
|
|
||||||
|
|
||||||
make_stock_entry(
|
make_stock_entry(
|
||||||
item_code=item,
|
item_code=SERIAL_ITEM,
|
||||||
to_warehouse="_Test Warehouse - _TC",
|
to_warehouse=WAREHOUSE,
|
||||||
qty=3,
|
qty=3,
|
||||||
rate=100,
|
rate=100,
|
||||||
posting_date="2026-06-01",
|
posting_date="2026-06-01",
|
||||||
)
|
)
|
||||||
make_stock_entry(
|
make_stock_entry(
|
||||||
item_code=item,
|
item_code=SERIAL_ITEM,
|
||||||
from_warehouse="_Test Warehouse - _TC",
|
from_warehouse=WAREHOUSE,
|
||||||
qty=1,
|
qty=1,
|
||||||
posting_date="2026-06-02",
|
posting_date="2026-06-02",
|
||||||
)
|
)
|
||||||
|
|
||||||
data = self.run_report(item_code=item)
|
data = self.run_report(item_code=SERIAL_ITEM)
|
||||||
|
|
||||||
flagged_items = {row.get("item_code") for row in data if isinstance(row, dict)}
|
flagged_items = {row.get("item_code") for row in data if isinstance(row, dict)}
|
||||||
self.assertNotIn(item, flagged_items)
|
self.assertNotIn(SERIAL_ITEM, flagged_items)
|
||||||
|
|
||||||
def test_only_balance_row_when_filtered_to_healthy_item(self):
|
def test_only_balance_row_when_filtered_to_healthy_item(self):
|
||||||
item = self.make_serial_item()
|
|
||||||
|
|
||||||
make_stock_entry(
|
make_stock_entry(
|
||||||
item_code=item,
|
item_code=SERIAL_ITEM,
|
||||||
to_warehouse="_Test Warehouse - _TC",
|
to_warehouse=WAREHOUSE,
|
||||||
qty=3,
|
qty=3,
|
||||||
rate=100,
|
rate=100,
|
||||||
posting_date="2026-06-01",
|
posting_date="2026-06-01",
|
||||||
)
|
)
|
||||||
|
|
||||||
data = self.run_report(item_code=item)
|
data = self.run_report(item_code=SERIAL_ITEM)
|
||||||
|
|
||||||
# The report always appends a single "Balance" summary row. A healthy
|
# The report always appends a single "Balance" summary row. A healthy
|
||||||
# serial item contributes no detail rows, so only that summary remains.
|
# serial item contributes no detail rows, so only that summary remains.
|
||||||
|
|||||||
Reference in New Issue
Block a user