File size: 3,250 Bytes
6ea7409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/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")