import pandas as pd from app.analysis import detect_query_type, count_keyword_rows, THANKS_KEYWORDS, COMPLAINT_KEYWORDS def test_detect_query_type_thanks(): t = "כמה משתמשים כתבו תודה על השירות" qtype, target = detect_query_type(t) assert qtype == "count_thanks" def test_detect_query_type_complaint(): t = "כמה אנשים מדווחים על תקלה במערכת" qtype, target = detect_query_type(t) assert qtype == "count_complaint" def test_count_keyword_rows_counts_thanks(): df = pd.DataFrame({"Text": ["תודה על השירות", "לא טוב", "תודה רבה!", "שדרוג נחמד"]}) cnt = count_keyword_rows(df, THANKS_KEYWORDS, text_column="Text") assert cnt == 2 def test_count_keyword_rows_counts_complaints(): df = pd.DataFrame({"Text": ["אין שגיאה", "תיקון נדרש", "יש תקלה", "נכשל בעבודה"]}) # Notice: keywords are Hebrew complaint variants; expect matches >=1 cnt = count_keyword_rows(df, COMPLAINT_KEYWORDS, text_column="Text") assert cnt >= 1