-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lambda.py
More file actions
42 lines (34 loc) · 982 Bytes
/
test_lambda.py
File metadata and controls
42 lines (34 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Test if the lambda handler is working."""
import sys
import os
import json
# Add backend to path
sys.path.insert(0, os.getcwd())
os.environ['DATABASE_URL'] = 'test'
os.environ['USE_DATABASE'] = 'false'
os.environ['ENABLE_OCR_FALLBACK'] = 'false'
try:
from mangum import Mangum
from app.main import app
handler = Mangum(app, lifespan="off")
# Simulate a Lambda event for /health
event = {
"requestContext": {
"http": {
"method": "GET",
"path": "/health"
}
},
"rawPath": "/health",
"headers": {
"accept": "application/json"
}
}
print("Testing handler with /health endpoint...")
print(f"Event: {json.dumps(event, indent=2)}")
response = handler(event, {})
print(f"\nResponse: {json.dumps(response, indent=2)}")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()