#!/usr/bin/env python3 """ Test Name Request Functionality """ from customer_manager import CustomerManager import os # Clean test - yeni database if os.path.exists("test_customers.json"): os.remove("test_customers.json") crm = CustomerManager("test_customers.json") print("🧪 İsim Sorma Test Senaryoları") print("="*50) # Test 1: Rezervasyon anında isim sorma print("\n1️⃣ REZERVASYON ANINDA İSİM SORMA") phone = "+905551111111" message = "Marlin 5'i rezerve edebilir miyim?" customer = crm.get_or_create_customer(phone) should_ask, question = crm.should_ask_for_name(phone, message) print(f"Müşteri: {message}") print(f"İsim sorulmalı mı: {should_ask}") if question: print(f"Soru: {question}") # Müşteri cevap veriyor print("\nMüşteri yanıtı: 'Ahmet'") extracted = crm.extract_name_from_response("Ahmet") print(f"Çıkarılan isim: {extracted}") # Test 2: 3. mesajda nazikçe sorma print("\n2️⃣ 3. MESAJDA NAZİKÇE SORMA") phone2 = "+905552222222" # 1. mesaj crm.update_interaction(phone2, "Merhaba", None) should_ask, question = crm.should_ask_for_name(phone2, "Merhaba") print(f"1. mesaj - İsim sorulmalı: {should_ask}") # 2. mesaj crm.update_interaction(phone2, "FX 3 var mı?", "FX 3") should_ask, question = crm.should_ask_for_name(phone2, "FX 3 var mı?") print(f"2. mesaj - İsim sorulmalı: {should_ask}") # 3. mesaj crm.update_interaction(phone2, "Fiyatı nedir?", None) should_ask, question = crm.should_ask_for_name(phone2, "Fiyatı nedir?") print(f"3. mesaj - İsim sorulmalı: {should_ask}") if question: print(f"Soru: {question}") # Test 3: Farklı isim formatları print("\n3️⃣ İSİM ÇIKARMA TESTLERİ") test_responses = [ "Mehmet", "benim adım Ali", "Ben Ayşe", "Adım Fatma", "ismim Hasan", "Veli, teşekkürler", "Ahmet Yılmaz", # İsim + Soyisim "selam" # İsim değil ] for response in test_responses: extracted = crm.extract_name_from_response(response) print(f"'{response}' -> {extracted if extracted else 'İsim bulunamadı'}") # Test 4: Mağaza ziyareti print("\n4️⃣ MAĞAZA ZİYARETİ ANINDA") phone3 = "+905553333333" message = "Yarın mağazaya gelerek test sürüşü yapabilir miyim?" should_ask, question = crm.should_ask_for_name(phone3, message) print(f"Müşteri: {message}") print(f"İsim sorulmalı: {should_ask}") if question: print(f"Soru: {question}") # Test 5: Ödeme görüşmesi print("\n5️⃣ ÖDEME GÖRÜŞMESİ ANINDA") phone4 = "+905554444444" message = "12 taksit yapıyor musunuz?" should_ask, question = crm.should_ask_for_name(phone4, message) print(f"Müşteri: {message}") print(f"İsim sorulmalı: {should_ask}") if question: print(f"Soru: {question}") # Test 6: 5+ sorgudan sonra print("\n6️⃣ POTANSİYEL MÜŞTERİ (5+ SORGU)") phone5 = "+905555555555" for i in range(5): crm.update_interaction(phone5, f"Soru {i+1}", None) should_ask, question = crm.should_ask_for_name(phone5, "Başka model var mı?") print(f"5+ sorgudan sonra") print(f"İsim sorulmalı: {should_ask}") if question: print(f"Soru: {question}") print("\n" + "="*50) print("✅ Testler Tamamlandı!") # Cleanup if os.path.exists("test_customers.json"): os.remove("test_customers.json")