12th_fix error
This commit is contained in:
43
test_routes.py
Normal file
43
test_routes.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
測試路由註冊
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
BASE_URL = 'http://127.0.0.1:5000'
|
||||
|
||||
def test_routes():
|
||||
"""測試各種路由是否正確註冊"""
|
||||
routes_to_test = [
|
||||
'/api/v1/auth/health',
|
||||
'/api/v1/notifications',
|
||||
'/api/v1/jobs',
|
||||
'/api/v1/health'
|
||||
]
|
||||
|
||||
print("Testing route registration...")
|
||||
|
||||
for route in routes_to_test:
|
||||
try:
|
||||
url = f"{BASE_URL}{route}"
|
||||
response = requests.get(url, timeout=5)
|
||||
|
||||
if response.status_code == 404:
|
||||
print(f"❌ {route} -> 404 NOT FOUND")
|
||||
elif response.status_code == 401:
|
||||
print(f"✅ {route} -> 401 UNAUTHORIZED (route exists, needs auth)")
|
||||
elif response.status_code == 200:
|
||||
print(f"✅ {route} -> 200 OK")
|
||||
else:
|
||||
print(f"🟡 {route} -> {response.status_code} {response.reason}")
|
||||
|
||||
except requests.exceptions.ConnectionError:
|
||||
print(f"❌ {route} -> CONNECTION ERROR")
|
||||
except Exception as e:
|
||||
print(f"❌ {route} -> ERROR: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_routes()
|
Reference in New Issue
Block a user