workorder-ingest/test_local.py
Adam Moussa df65d34eb0 Initial commit: work order email ingestion pipeline
Serverless AWS pipeline that receives Amazon APM work order emails via SES,
parses them with Claude AI, and stores structured data in DynamoDB. Includes
a web UI dashboard for viewing work orders and event history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 16:37:04 -04:00

48 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""
Local test script - parses sample emails through Claude without AWS.
Usage:
export ANTHROPIC_API_KEY=sk-ant-...
python test_local.py
"""
import json
import sys
from pathlib import Path
# Add project root to path so we can import the handler's parsing logic
sys.path.insert(0, str(Path(__file__).parent / "lambdas" / "email_processor"))
from handler import parse_raw_email, extract_with_claude
def main():
samples_dir = Path(__file__).parent / "samples"
eml_files = list(samples_dir.glob("*.eml"))
if not eml_files:
print("No .eml files found in samples/")
return
for eml_path in eml_files:
print(f"\n{'='*80}")
print(f"FILE: {eml_path.name}")
print(f"{'='*80}")
raw = eml_path.read_bytes()
email_data = parse_raw_email(raw)
print(f"Subject: {email_data['subject']}")
print(f"From: {email_data['sender']}")
print(f"Date: {email_data['date']}")
print(f"Body preview: {email_data['body'][:200]}...")
print()
print("Sending to Claude for extraction...")
parsed = extract_with_claude(email_data)
print(json.dumps(parsed, indent=2))
if __name__ == "__main__":
main()