Chris4K's picture
Upload 195 files
4c75d73 verified
#!/usr/bin/env python3
"""
Test script for Read2Burn mailbox functionality
"""
import sys
import os
# Add the src directory to Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
def test_read2burn():
try:
from src.addons.read2burn_addon import read2burn_service
print("🧪 Testing Read2Burn Mailbox...")
# Test player ID
player_id = "test_player_123"
print("\n📝 Testing Message Creation...")
# Test creating messages
result1 = read2burn_service.handle_command(player_id, "create This is a secret message!")
print(f"📤 Create command result: {result1}")
result2 = read2burn_service.handle_command(player_id, "create Another confidential note")
print(f"📤 Create command result: {result2}")
print("\n📋 Testing Message Listing...")
# Test listing messages
list_result = read2burn_service.handle_command(player_id, "list")
print(f"📜 List command result: {list_result}")
print("\n📖 Testing Message Reading...")
# Extract message ID from first create result to test reading
import re
match = re.search(r'Message ID:\*\* `([^`]+)`', result1)
if match:
message_id = match.group(1)
print(f"🔍 Found message ID: {message_id}")
# Test reading the message
read_result = read2burn_service.handle_command(player_id, f"read {message_id}")
print(f"📖 Read command result: {read_result}")
# Try to read again (should be burned)
read_again = read2burn_service.handle_command(player_id, f"read {message_id}")
print(f"🔥 Read again result: {read_again}")
print("\n❓ Testing Help Command...")
help_result = read2burn_service.handle_command(player_id, "help")
print(f"💡 Help command result: {help_result}")
print("\n📊 Testing Message History...")
history = read2burn_service.get_player_message_history(player_id)
print(f"📈 Message history: {len(history)} entries")
for entry in history:
print(f" - {entry}")
print("\n✅ Read2Burn test completed successfully!")
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_read2burn()