ciyidogan commited on
Commit
55a98ca
·
verified ·
1 Parent(s): ca2a223

Update intent_test_runner.py

Browse files
Files changed (1) hide show
  1. intent_test_runner.py +2 -12
intent_test_runner.py CHANGED
@@ -6,7 +6,6 @@ from log import log
6
  BASE_URL = os.environ.get("BASE_URL", "http://localhost:7860")
7
  SERVICE_CONFIG_PATH = os.environ.get("SERVICE_CONFIG_PATH", "service_config.json")
8
 
9
- # Config dosyasını yükle
10
  with open(SERVICE_CONFIG_PATH, "r", encoding="utf-8") as f:
11
  service_config = json.load(f)
12
 
@@ -20,11 +19,7 @@ def assert_test(name, actual, expected_substring, explanation=None):
20
  if explanation:
21
  log(f"🧪 TEST: {name} → {explanation}")
22
  actual_str = str(actual)
23
-
24
- if "fallback" in name.lower():
25
- passed = any(ans in actual_str for ans in fallback_answers)
26
- else:
27
- passed = expected_substring in actual_str
28
 
29
  if passed:
30
  log(f"[TEST] {name:<45} ✅")
@@ -56,20 +51,16 @@ def run_all_tests():
56
 
57
  headers = {"X-Session-ID": session_id}
58
 
59
- # ✅ Fallback testi: hiçbir intent'e eşleşmeyen
60
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": "Mars'a bilet alabilir miyim?"}, headers=headers)
61
  assert_test("LLM fallback", r.json(), "")
62
 
63
- # Döviz kuru testi
64
- valid_currency = currency_options[0] # örn: dolar
65
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": f"{valid_currency} kuru nedir"}, headers=headers)
66
  assert_test("Parametre tamamlandı — dolar", r.json(), f"{valid_currency} kuru şu an")
67
 
68
- # ✅ Geçersiz currency testi
69
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": "yenidolar kuru nedir"}, headers=headers)
70
  assert_test("Geçersiz parametre — currency", r.json(), "Geçerli bir döviz cinsi")
71
 
72
- # ✅ Yol durumu zinciri
73
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": "yol durumu"}, headers=headers)
74
  assert_test("Eksik parametre — from_location", r.json(), "Lütfen from_location")
75
 
@@ -79,7 +70,6 @@ def run_all_tests():
79
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": city_options[1]}, headers=headers)
80
  assert_test("Parametre tamamlandı — yol durumu", r.json(), "trafik açık")
81
 
82
- # ✅ Hava durumu zinciri
83
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": "hava durumu"}, headers=headers)
84
  assert_test("Eksik parametre — city", r.json(), "Lütfen city")
85
 
 
6
  BASE_URL = os.environ.get("BASE_URL", "http://localhost:7860")
7
  SERVICE_CONFIG_PATH = os.environ.get("SERVICE_CONFIG_PATH", "service_config.json")
8
 
 
9
  with open(SERVICE_CONFIG_PATH, "r", encoding="utf-8") as f:
10
  service_config = json.load(f)
11
 
 
19
  if explanation:
20
  log(f"🧪 TEST: {name} → {explanation}")
21
  actual_str = str(actual)
22
+ passed = any(ans in actual_str for ans in fallback_answers) if "fallback" in name.lower() else expected_substring in actual_str
 
 
 
 
23
 
24
  if passed:
25
  log(f"[TEST] {name:<45} ✅")
 
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", r.json(), "Lütfen from_location")
66
 
 
70
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": city_options[1]}, headers=headers)
71
  assert_test("Parametre tamamlandı — yol durumu", r.json(), "trafik açık")
72
 
 
73
  r = requests.post(f"{BASE_URL}/chat", json={"user_input": "hava durumu"}, headers=headers)
74
  assert_test("Eksik parametre — city", r.json(), "Lütfen city")
75