BF-WAB / test_crm.py
samikoen
Deploy from GitHub Actions
6ea7409
#!/usr/bin/env python3
"""
CRM System Test Script
"""
from customer_manager import CustomerManager
# Test CRM
print("🧪 CRM Test Başlatılıyor...")
print("="*50)
# Initialize CRM
crm = CustomerManager()
# Test 1: Yeni müşteri oluşturma
print("\n1️⃣ Yeni müşteri test ediliyor...")
customer1 = crm.get_or_create_customer("+905551234567", "Ahmet")
print(f" ✅ Müşteri oluşturuldu: {customer1['name']} - {customer1['segment']}")
# Test 2: İkinci mesaj - selamlama
print("\n2️⃣ Selamlama mesajı testi...")
context = crm.get_customer_context("+905551234567")
print(f" Selamlama: {context['greeting']}")
# Test 3: Ürün araması güncelleme
print("\n3️⃣ Ürün araması güncelleme testi...")
crm.update_interaction("+905551234567", "Marlin 5 var mı?", "Marlin 5")
customer1 = crm.customers["+905551234567"]
print(f" İlgi alanları: {customer1['interests']}")
print(f" Toplam sorgu: {customer1['total_queries']}")
# Test 4: Başka bir müşteri - VIP simülasyonu
print("\n4️⃣ VIP müşteri testi...")
customer2 = crm.get_or_create_customer("+905559876543", "Mehmet")
# Birkaç satın alma ekle
crm.add_purchase("+905559876543", "Trek Madone SLR 9", 180000)
crm.add_purchase("+905559876543", "Trek Domane SL 7", 95000)
crm.add_purchase("+905559876543", "Trek FX Sport 6", 45000)
customer2 = crm.customers["+905559876543"]
print(f" ✅ VIP Müşteri: {customer2['name']} - {customer2['segment']}")
context2 = crm.get_customer_context("+905559876543")
print(f" VIP Selamlama: {context2['greeting']}")
# Test 5: Analitik
print("\n5️⃣ Analitik raporu...")
analytics = crm.get_analytics()
print(f" Toplam müşteri: {analytics['total_customers']}")
print(f" Segment dağılımı: {analytics['segments']}")
print(f" Toplam satış: {analytics['total_purchases']}")
print(f" Toplam gelir: ₺{analytics['total_revenue']:,.0f}")
# Test 6: Müşteri listesi
print("\n6️⃣ Müşteri listesi...")
customers = crm.get_customer_list()
for customer in customers:
print(f" - {customer['name']} ({customer['phone']}) - {customer['segment']} - {customer['total_queries']} sorgu")
print("\n" + "="*50)
print("✅ CRM Testleri Tamamlandı!")
print("\n📊 Dashboard'u görmek için:")
print(" http://localhost:8000/crm-analytics")