Spaces:
Sleeping
Sleeping
Upload test_admin_stats.py
Browse files- test_admin_stats.py +7 -13
test_admin_stats.py
CHANGED
|
@@ -1,26 +1,20 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
|
| 4 |
-
# Add app to path
|
| 5 |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__))))
|
| 6 |
|
| 7 |
from app.db.base import SessionLocal
|
| 8 |
-
from app.api.admin import get_dashboard_stats
|
| 9 |
|
| 10 |
def run():
|
| 11 |
db = SessionLocal()
|
| 12 |
-
# Mock user_id 1 (assume admin for test or bypass check_admin temporarily for script or just pass admin user id)
|
| 13 |
-
# The check_admin function needs a real admin user ID.
|
| 14 |
-
# Let's just catch the exception and see what check_admin complains about if user 1 is not admin.
|
| 15 |
try:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
res = get_dashboard_stats(admin.id, db)
|
| 23 |
-
print("Success:", res)
|
| 24 |
except Exception as e:
|
| 25 |
print("Error:", e)
|
| 26 |
finally:
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
|
|
|
|
| 4 |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__))))
|
| 5 |
|
| 6 |
from app.db.base import SessionLocal
|
| 7 |
+
from app.api.admin import get_dashboard_stats, get_chart_data
|
| 8 |
|
| 9 |
def run():
|
| 10 |
db = SessionLocal()
|
|
|
|
|
|
|
|
|
|
| 11 |
try:
|
| 12 |
+
res1 = get_dashboard_stats(1, db)
|
| 13 |
+
print("Success stats:", res1)
|
| 14 |
+
|
| 15 |
+
res2 = get_chart_data(1, db)
|
| 16 |
+
print("Success charts:", len(res2["value"]), "days of data")
|
| 17 |
+
|
|
|
|
|
|
|
| 18 |
except Exception as e:
|
| 19 |
print("Error:", e)
|
| 20 |
finally:
|