-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_code_extraction.py
More file actions
48 lines (38 loc) Β· 1.61 KB
/
test_code_extraction.py
File metadata and controls
48 lines (38 loc) Β· 1.61 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
"""
Test script to check verification code extraction from AgentMail.
"""
from agentmail_helper import get_latest_verification_code, AgentMailHelper
def test_code_extraction():
"""Test the verification code extraction"""
print("π Testing Verification Code Extraction...")
# Test the latest verification code
code = get_latest_verification_code()
if code:
print(f"β
Latest verification code: {code}")
else:
print("β No verification code found")
# Test with the helper class
helper = AgentMailHelper()
helper.setup()
try:
messages_response = helper.client.inboxes.messages.list(
inbox_id=helper.inbox_id
)
print(f"\nπ§ Found {len(messages_response.messages)} messages in inbox")
for i, message in enumerate(messages_response.messages, 1):
print(f"\nπ¨ Message {i}:")
print(f" Subject: {getattr(message, 'subject', 'No subject')}")
print(f" Preview: {getattr(message, 'preview', 'No preview')}")
if helper._is_verification_email(message):
print(" β
Detected as verification email")
code = helper._extract_verification_code(message)
if code:
print(f" π Extracted code: {code}")
else:
print(" β No code extracted")
else:
print(" β Not a verification email")
except Exception as e:
print(f"β Error: {e}")
if __name__ == "__main__":
test_code_extraction()