65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test the fixed bulk email task without Django setup.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Add project root to path
|
|
sys.path.insert(0, "/home/ismail/projects/ats/kaauh_ats")
|
|
|
|
|
|
def test_bulk_email_task():
|
|
"""Test the bulk email task function directly."""
|
|
try:
|
|
# Import the function directly
|
|
from recruitment.tasks.email_tasks import send_bulk_email_task
|
|
|
|
# Test new format
|
|
result1 = send_bulk_email_task(
|
|
{
|
|
"subject": "Test Subject",
|
|
"recipients_data": [{"email": "test@example.com", "name": "Test User"}],
|
|
"sender_id": 1,
|
|
"job_id": 1,
|
|
}
|
|
)
|
|
|
|
print("✓ New format test result:", result1)
|
|
|
|
# Test old format
|
|
result2 = send_bulk_email_task(
|
|
subject="Test Subject",
|
|
customized_sends=[{"email": "test@example.com", "name": "Test User"}],
|
|
sender_user_id=1,
|
|
job_id=1,
|
|
)
|
|
|
|
print("✓ Old format test result:", result2)
|
|
|
|
# Check if both work
|
|
success1 = result1.get("success", False)
|
|
success2 = result2.get("success", False)
|
|
|
|
if success1 and success2:
|
|
print("✅ Both formats work correctly!")
|
|
return True
|
|
else:
|
|
print("❌ One or both formats failed")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"❌ Test failed: {e}")
|
|
return False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("Testing bulk email task function...")
|
|
success = test_bulk_email_task()
|
|
|
|
if success:
|
|
print("🎉 Bulk email task function is working correctly!")
|
|
else:
|
|
print("❌ Bulk email task function has issues")
|