mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 17:04:47 +00:00
refactor(test): make bom tests deterministic
This commit is contained in:
@@ -394,6 +394,7 @@ class TestBOM(ERPNextTestSuite):
|
|||||||
item_code = make_item(properties={"is_stock_item": 1}).name
|
item_code = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
|
||||||
bom = frappe.new_doc("BOM")
|
bom = frappe.new_doc("BOM")
|
||||||
|
bom.company = self.companies[0].name
|
||||||
bom.item = item_code
|
bom.item = item_code
|
||||||
bom.append("items", frappe._dict(item_code=item_code))
|
bom.append("items", frappe._dict(item_code=item_code))
|
||||||
bom.save()
|
bom.save()
|
||||||
@@ -407,11 +408,13 @@ class TestBOM(ERPNextTestSuite):
|
|||||||
item2 = make_item(properties={"is_stock_item": 1}).name
|
item2 = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
|
||||||
bom1 = frappe.new_doc("BOM")
|
bom1 = frappe.new_doc("BOM")
|
||||||
|
bom1.company = self.companies[0].name
|
||||||
bom1.item = item1
|
bom1.item = item1
|
||||||
bom1.append("items", frappe._dict(item_code=item2))
|
bom1.append("items", frappe._dict(item_code=item2))
|
||||||
bom1.save()
|
bom1.save()
|
||||||
|
|
||||||
bom2 = frappe.new_doc("BOM")
|
bom2 = frappe.new_doc("BOM")
|
||||||
|
bom2.company = self.companies[0].name
|
||||||
bom2.item = item2
|
bom2.item = item2
|
||||||
bom2.append("items", frappe._dict(item_code=item1))
|
bom2.append("items", frappe._dict(item_code=item1))
|
||||||
bom2.save()
|
bom2.save()
|
||||||
@@ -569,6 +572,7 @@ class TestBOM(ERPNextTestSuite):
|
|||||||
@timeout
|
@timeout
|
||||||
def test_clear_inpection_quality(self):
|
def test_clear_inpection_quality(self):
|
||||||
bom = frappe.copy_doc(self.globalTestRecords["BOM"][2], ignore_no_copy=True)
|
bom = frappe.copy_doc(self.globalTestRecords["BOM"][2], ignore_no_copy=True)
|
||||||
|
bom.company = self.companies[0].name
|
||||||
bom.docstatus = 0
|
bom.docstatus = 0
|
||||||
bom.is_default = 0
|
bom.is_default = 0
|
||||||
bom.quality_inspection_template = "_Test Quality Inspection Template"
|
bom.quality_inspection_template = "_Test Quality Inspection Template"
|
||||||
@@ -614,6 +618,7 @@ class TestBOM(ERPNextTestSuite):
|
|||||||
|
|
||||||
# Step 1: Create BOM
|
# Step 1: Create BOM
|
||||||
bom = frappe.new_doc("BOM")
|
bom = frappe.new_doc("BOM")
|
||||||
|
bom.company = self.companies[0].name
|
||||||
bom.item = fg_item.item_code
|
bom.item = fg_item.item_code
|
||||||
bom.quantity = 1
|
bom.quantity = 1
|
||||||
bom.append(
|
bom.append(
|
||||||
|
|||||||
@@ -242,6 +242,8 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
cls.make_workstation()
|
cls.make_workstation()
|
||||||
cls.make_operation()
|
cls.make_operation()
|
||||||
cls.make_bom()
|
cls.make_bom()
|
||||||
|
cls.make_quality_inspection_param()
|
||||||
|
cls.make_quality_inspection_template()
|
||||||
cls.update_selling_settings()
|
cls.update_selling_settings()
|
||||||
cls.update_stock_settings()
|
cls.update_stock_settings()
|
||||||
cls.update_system_settings()
|
cls.update_system_settings()
|
||||||
@@ -2839,6 +2841,48 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
cls.bom.append(frappe.get_doc("BOM", {"item": x.get("item"), "company": x.get("company")}))
|
cls.bom.append(frappe.get_doc("BOM", {"item": x.get("item"), "company": x.get("company")}))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def make_quality_inspection_param(cls):
|
||||||
|
records = [{"doctype": "Quality Inspection Parameter", "parameter": "_Test Param"}]
|
||||||
|
cls.quality_inspection_param = []
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists("Quality Inspection Parameter", {"parameter": x.get("parameter")}):
|
||||||
|
cls.quality_inspection_param.append(frappe.get_doc(x).insert())
|
||||||
|
else:
|
||||||
|
cls.quality_inspection_param.append(
|
||||||
|
frappe.get_doc("Quality Inspection Parameter", {"parameter": x.get("parameter")})
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def make_quality_inspection_template(cls):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"quality_inspection_template_name": "_Test Quality Inspection Template",
|
||||||
|
"doctype": "Quality Inspection Template",
|
||||||
|
"item_quality_inspection_parameter": [
|
||||||
|
{
|
||||||
|
"specification": cls.quality_inspection_param[0].name,
|
||||||
|
"doctype": "Item Quality Inspection Parameter",
|
||||||
|
"parentfield": "item_quality_inspection_parameter",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
cls.quality_inspection_template = []
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists(
|
||||||
|
"Quality Inspection Template",
|
||||||
|
{"quality_inspection_template_name": x.get("quality_inspection_template_name")},
|
||||||
|
):
|
||||||
|
cls.quality_inspection_template.append(frappe.get_doc(x).insert())
|
||||||
|
else:
|
||||||
|
cls.quality_inspection_template.append(
|
||||||
|
frappe.get_doc(
|
||||||
|
"Quality Inspection Template",
|
||||||
|
{"quality_inspection_template_name": x.get("quality_inspection_template_name")},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def set_user(self, user: str):
|
def set_user(self, user: str):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user