Spaces:
Paused
Paused
Update intent_test_runner.py
Browse files- intent_test_runner.py +8 -2
intent_test_runner.py
CHANGED
@@ -19,8 +19,7 @@ def assert_test(name, actual, expected_substring, explanation=None):
|
|
19 |
if explanation:
|
20 |
log(f"🧪 TEST: {name} → {explanation}")
|
21 |
actual_str = str(actual)
|
22 |
-
passed =
|
23 |
-
|
24 |
if passed:
|
25 |
log(f"[TEST] {name:<45} ✅")
|
26 |
test_results.append((name, True))
|
@@ -51,25 +50,32 @@ def run_all_tests():
|
|
51 |
|
52 |
headers = {"X-Session-ID": session_id}
|
53 |
|
|
|
54 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "Mars'a bilet alabilir miyim?"}, headers=headers)
|
55 |
assert_test("LLM fallback", r.json(), "")
|
56 |
|
|
|
57 |
valid_currency = currency_options[0]
|
58 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{valid_currency} kuru nedir"}, headers=headers)
|
59 |
assert_test("Parametre tamamlandı — dolar", r.json(), f"{valid_currency} kuru şu an")
|
60 |
|
|
|
61 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "yenidolar kuru nedir"}, headers=headers)
|
62 |
assert_test("Geçersiz parametre — currency", r.json(), "Geçerli bir döviz cinsi")
|
63 |
|
|
|
64 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "yol durumu"}, headers=headers)
|
65 |
assert_test("Eksik parametre — from_location & to_location", r.json(), "Lütfen şu bilgileri sırayla belirtir misiniz")
|
66 |
|
|
|
67 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{city_options[0]} {city_options[1]}"}, headers=headers)
|
68 |
assert_test("Parametre tamamlandı — yol durumu", r.json(), "trafik açık")
|
69 |
|
|
|
70 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "hava durumu"}, headers=headers)
|
71 |
assert_test("Eksik parametre — city", r.json(), "Lütfen şu bilgileri sırayla belirtir misiniz")
|
72 |
|
|
|
73 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{city_options[0]}"}, headers=headers)
|
74 |
assert_test("Parametre tamamlandı — hava durumu", r.json(), f"{city_options[0]} için hava güneşli")
|
75 |
|
|
|
19 |
if explanation:
|
20 |
log(f"🧪 TEST: {name} → {explanation}")
|
21 |
actual_str = str(actual)
|
22 |
+
passed = expected_substring in actual_str
|
|
|
23 |
if passed:
|
24 |
log(f"[TEST] {name:<45} ✅")
|
25 |
test_results.append((name, True))
|
|
|
50 |
|
51 |
headers = {"X-Session-ID": session_id}
|
52 |
|
53 |
+
# === Test 1: LLM fallback
|
54 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "Mars'a bilet alabilir miyim?"}, headers=headers)
|
55 |
assert_test("LLM fallback", r.json(), "")
|
56 |
|
57 |
+
# === Test 2: Döviz kuru — başarılı
|
58 |
valid_currency = currency_options[0]
|
59 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{valid_currency} kuru nedir"}, headers=headers)
|
60 |
assert_test("Parametre tamamlandı — dolar", r.json(), f"{valid_currency} kuru şu an")
|
61 |
|
62 |
+
# === Test 3: Döviz kuru — geçersiz parametre
|
63 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "yenidolar kuru nedir"}, headers=headers)
|
64 |
assert_test("Geçersiz parametre — currency", r.json(), "Geçerli bir döviz cinsi")
|
65 |
|
66 |
+
# === Test 4: Yol durumu — eksik parametreleri isteme
|
67 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "yol durumu"}, headers=headers)
|
68 |
assert_test("Eksik parametre — from_location & to_location", r.json(), "Lütfen şu bilgileri sırayla belirtir misiniz")
|
69 |
|
70 |
+
# === Test 4b: Yol durumu — eksik parametreleri tamamlama ve doğrulama
|
71 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{city_options[0]} {city_options[1]}"}, headers=headers)
|
72 |
assert_test("Parametre tamamlandı — yol durumu", r.json(), "trafik açık")
|
73 |
|
74 |
+
# === Test 5: Hava durumu — eksik parametre isteme
|
75 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": "hava durumu"}, headers=headers)
|
76 |
assert_test("Eksik parametre — city", r.json(), "Lütfen şu bilgileri sırayla belirtir misiniz")
|
77 |
|
78 |
+
# === Test 5b: Hava durumu — parametre tamamlama ve doğrulama
|
79 |
r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{city_options[0]}"}, headers=headers)
|
80 |
assert_test("Parametre tamamlandı — hava durumu", r.json(), f"{city_options[0]} için hava güneşli")
|
81 |
|