def before_tests():
frappe.clear_cache()
# complete setup if missing
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
if not frappe.get_list("Company"):
setup_complete({
"currency" :"USD",
"full_name" :"Test User",
"company_name" :"Wind Power LLC",
"timezone" :"America/New_York",
"company_abbr" :"WP",
"industry" :"Manufacturing",
"country" :"United States",
"fy_start_date" :"2011-01-01",
"fy_end_date" :"2011-12-31",
"language" :"english",
"company_tagline" :"Testing",
"email" :"test@erpnext.com",
"password" :"test",
"chart_of_accounts" : "Standard",
"domains" : ["Manufacturing"],
})
frappe.db.sql("delete from `tabLeave Allocation`")
frappe.db.sql("delete from `tabLeave Application`")
frappe.db.sql("delete from `tabSalary Slip`")
frappe.db.sql("delete from `tabItem Price`")
frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 0)
enable_all_roles_and_domains()
frappe.db.commit()
Hi guys, When i ran my test file, all of a sudden my data gone missing. i found out that running the test in frappe is quite dangerous especially if the test is related to those tables. I am just curious, if any significant to the code above? what is the purpose. can we make it default not to touch any of the tables unless we do it intentionally?
i realized that there a way that we can skip the before test method by specifying --skip-before-tests, but it is not default.