-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
62 lines (55 loc) · 1.97 KB
/
test.py
File metadata and controls
62 lines (55 loc) · 1.97 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
###############################################################################
# test.py – Local smoke tests for the “embed‑one” Lambda
#
# Prerequisites
# ─────────────
# 1. Export or source your .env (same vars the Lambda uses):
# export $(grep -v '^#' .env | xargs)
#
# 2. Your AWS CLI default profile *must* have:
# • s3:GetObject on $S3_BUCKET_FRAMES
# • bedrock:InvokeModel on Titan G1
# • aoss:APIAccessAll (or equivalent read/write) on the collection
#
# 3. `lambda_function.py` must be import‑able from the current directory.
#
# Usage
# ─────
# python3 test.py
#
###############################################################################
import os
import json
from lambda_function import lambda_handler
# ─── Configurable test set ──────────────────────────────────────────
# List a couple of platform+code pairs that you KNOW already have
# • frames/0.jpg … in S3
# • is_extracted = true, is_embedded = false in Supabase
TEST_VIDEOS = [
("instagram", "DIB0wE1SHVa"),
]
def build_event(pairs):
"""Emulate the SQS event structure used in production."""
return {
"Records": [
{"body": json.dumps({"platform": p, "code": c})}
for p, c in pairs
]
}
def test_bulk():
print("» BULK test on", len(TEST_VIDEOS), "videos")
event = build_event(TEST_VIDEOS)
result = lambda_handler(event, None)
print(json.dumps(result, indent=2))
def test_single():
print("» SINGLE video test")
event = build_event([TEST_VIDEOS[0]])
result = lambda_handler(event, None)
print(json.dumps(result, indent=2))
if __name__ == "__main__":
# Force DEBUG logging inside the Lambda (if you wired that env var)
os.environ.setdefault("LOG_LEVEL", "DEBUG")
test_bulk()
print("\n" + "=" * 70 + "\n")
test_single()