Files
shopback/test_contact_api.py
Beyhan Oğur d9f1ea341e first commit
2026-04-26 22:27:56 +03:00

55 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python
"""
Contact API Test Script
Bu script contact endpoint'ini test eder ve email gönderimini kontrol eder.
"""
import requests
import json
# API endpoint
BASE_URL = "http://127.0.0.1:8000"
CONTACT_URL = f"{BASE_URL}/api/v1/contact/create/"
# Test data
test_contact = {
"name": "Test Kullanıcı",
"email": "test@example.com",
"subject": "Test Konusu",
"message": "Bu bir test mesajıdır. Celery ile email gönderimi test ediliyor."
}
print("=" * 60)
print("Contact API Test")
print("=" * 60)
print(f"\nEndpoint: {CONTACT_URL}")
print(f"\nTest Data:")
print(json.dumps(test_contact, indent=2, ensure_ascii=False))
print("\n" + "=" * 60)
try:
# POST request gönder
response = requests.post(CONTACT_URL, json=test_contact)
print(f"\nResponse Status Code: {response.status_code}")
print(f"Response Headers: {dict(response.headers)}")
if response.status_code == 201:
print("\n✅ Contact başarıyla oluşturuldu!")
print(f"\nResponse Data:")
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
print("\n📧 Email gönderimi için Celery worker'ı kontrol edin.")
print(" MailPit: http://localhost:8025")
else:
print(f"\n❌ Hata! Status Code: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.ConnectionError:
print("\n❌ Bağlantı hatası! Django sunucusu çalışıyor mu?")
print(" Sunucuyu başlatmak için: python manage.py runserver")
except Exception as e:
print(f"\n❌ Beklenmeyen hata: {str(e)}")
print("\n" + "=" * 60)