@@ -23,10 +23,10 @@ def check(name):
2323 """Decorator to register a check"""
2424
2525 def decorator (f ):
26- def wrapper ():
26+ def wrapper (app ):
2727 global PASSED , FAILED
2828 try :
29- f ()
29+ f (app )
3030 PASSED += 1
3131 print (f" \033 [32m✓\033 [0m { name } " )
3232 return True
@@ -44,53 +44,43 @@ def wrapper():
4444
4545
4646# =============================================================================
47- # CHECKS - Add new checks here
47+ # CHECKS
4848# =============================================================================
4949
5050
5151@check ("App boots without errors" )
52- def check_app_boots ():
53- from enferno .app import create_app
54-
55- app = create_app ()
52+ def check_app_boots (app ):
5653 assert app is not None
5754 assert app .config ["SECRET_KEY" ]
5855
5956
6057@check ("Database connection works" )
61- def check_database ():
62- from enferno .app import create_app
58+ def check_database (app ):
6359 from enferno .extensions import db
6460
65- app = create_app ()
6661 with app .app_context ():
6762 db .session .execute (db .text ("SELECT 1" ))
6863
6964
7065@check ("User model loads" )
71- def check_user_model ():
72- from enferno .app import create_app
66+ def check_user_model (app ):
7367 from enferno .user .models import User
7468
75- app = create_app ()
7669 with app .app_context ():
77- # Just verify we can query without error
7870 User .query .limit (1 ).all ()
7971
8072
8173@check ("Workspace model and relationships" )
82- def check_workspace_model ():
83- from enferno .app import create_app
74+ def check_workspace_model (app ):
8475 from enferno .user .models import Membership , Workspace
8576
86- app = create_app ()
8777 with app .app_context ():
8878 Workspace .query .limit (1 ).all ()
8979 Membership .query .limit (1 ).all ()
9080
9181
9282@check ("Workspace service imports" )
93- def check_workspace_service ():
83+ def check_workspace_service (app ):
9484 from enferno .services .workspace import (
9585 WorkspaceScoped ,
9686 WorkspaceService ,
@@ -105,7 +95,7 @@ def check_workspace_service():
10595
10696
10797@check ("Billing service imports" )
108- def check_billing_service ():
98+ def check_billing_service (app ):
10999 from enferno .services .billing import HostedBilling , requires_pro_plan
110100
111101 assert callable (requires_pro_plan )
@@ -114,29 +104,23 @@ def check_billing_service():
114104
115105
116106@check ("Auth decorators work" )
117- def check_auth_decorators ():
107+ def check_auth_decorators (app ):
118108 from enferno .services .auth import require_superadmin , require_superadmin_api
119109
120110 assert callable (require_superadmin )
121111 assert callable (require_superadmin_api )
122112
123113
124114@check ("All blueprints register" )
125- def check_blueprints ():
126- from enferno .app import create_app
127-
128- app = create_app ()
115+ def check_blueprints (app ):
129116 blueprints = list (app .blueprints .keys ())
130117 required = ["users" , "public" , "portal" , "webhooks" ]
131118 for bp in required :
132119 assert bp in blueprints , f"Missing blueprint: { bp } "
133120
134121
135122@check ("Critical routes exist" )
136- def check_routes ():
137- from enferno .app import create_app
138-
139- app = create_app ()
123+ def check_routes (app ):
140124 rules = [r .rule for r in app .url_map .iter_rules ()]
141125
142126 critical_routes = [
@@ -150,10 +134,7 @@ def check_routes():
150134
151135
152136@check ("Security config is sane" )
153- def check_security_config ():
154- from enferno .app import create_app
155-
156- app = create_app ()
137+ def check_security_config (app ):
157138 # Password security
158139 assert app .config ["SECURITY_PASSWORD_LENGTH_MIN" ] >= 8
159140 # Session security
@@ -168,12 +149,15 @@ def check_security_config():
168149
169150
170151def run_checks ():
152+ from enferno .app import create_app
153+
171154 print ("\n \033 [1mRunning checks...\033 [0m\n " )
172155
156+ app = create_app ()
173157 checks = [v for v in globals ().values () if hasattr (v , "_check_name" )]
174158
175159 for check_fn in checks :
176- check_fn ()
160+ check_fn (app )
177161
178162 print ()
179163 if FAILED == 0 :
0 commit comments