refactor(test): make item deterministic

This commit is contained in:
ruthra kumar
2026-01-01 17:41:31 +05:30
parent 26d7900590
commit f758ee4adc
2 changed files with 48 additions and 8 deletions

View File

@@ -246,6 +246,7 @@ class ERPNextTestSuite(unittest.TestCase):
cls.make_quality_inspection_param()
cls.make_quality_inspection_template()
cls.make_employees()
cls.make_brand()
cls.update_selling_settings()
cls.update_stock_settings()
cls.update_system_settings()
@@ -2919,6 +2920,31 @@ class ERPNextTestSuite(unittest.TestCase):
)
)
@classmethod
def make_brand(cls):
records = [
{"brand": "_Test Brand", "doctype": "Brand"},
{
"brand": "_Test Brand With Item Defaults",
"doctype": "Brand",
"brand_defaults": [
{
"company": "_Test Company",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"income_account": "_Test Account Sales - _TC",
"buying_cost_center": "_Test Cost Center - _TC",
"selling_cost_center": "_Test Cost Center - _TC",
}
],
},
]
cls.brand = []
for x in records:
if not frappe.db.exists("Brand", {"brand": x.get("brand")}):
cls.brand.append(frappe.get_doc(x).insert())
else:
cls.brand.append(frappe.get_doc("Brand", {"Brand": x.get("brand")}))
@contextmanager
def set_user(self, user: str):
try: