#!/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()