From f442826a9725f444840a43b77a133ff5ad5ccff8 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:57:10 +0200 Subject: [PATCH] ci_ run setup wizard before tests --- simple_subscription/hooks.py | 2 +- simple_subscription/utils.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 simple_subscription/utils.py diff --git a/simple_subscription/hooks.py b/simple_subscription/hooks.py index 483b0ab..f56c94a 100644 --- a/simple_subscription/hooks.py +++ b/simple_subscription/hooks.py @@ -116,7 +116,7 @@ # Testing # ------- -# before_tests = "simple_subscription.install.before_tests" +before_tests = "simple_subscription.utils.before_tests" # Overriding Methods # ------------------------------ diff --git a/simple_subscription/utils.py b/simple_subscription/utils.py new file mode 100644 index 0000000..62a118b --- /dev/null +++ b/simple_subscription/utils.py @@ -0,0 +1,29 @@ +import frappe +from frappe.utils import now_datetime +from frappe.desk.page.setup_wizard.setup_wizard import setup_complete + + +def before_tests(): + # complete setup if missing + year = now_datetime().year + if not frappe.get_list("Company"): + setup_complete( + { + "currency": "EUR", + "full_name": "Test User", + "company_name": "Bolt Trades", + "timezone": "Europe/Berlin", + "company_abbr": "BT", + "industry": "Manufacturing", + "country": "Germany", + "fy_start_date": f"{year}-01-01", + "fy_end_date": f"{year}-12-31", + "language": "english", + "company_tagline": "Testing", + "email": "test@erpnext.com", + "password": "test", + "chart_of_accounts": "Standard", + } + ) + + frappe.db.commit() # nosemgrep