Spaces:
Sleeping
Sleeping
| """Tests for backend.resources — deterministic legal situation classifier. | |
| Tests the keyword-based heuristic that pre-classifies user input into legal | |
| categories before the LLM runs. No API keys or network access needed. | |
| """ | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) | |
| from backend.resources import classify_legal_situation_keywords | |
| class TestClassifyLegalSituation: | |
| def test_stalking(self): | |
| result = classify_legal_situation_keywords("Someone is stalking me everywhere I go") | |
| assert "stalking" in result.lower() or result != "" | |
| def test_domestic_violence(self): | |
| result = classify_legal_situation_keywords("My husband beats me every day") | |
| assert result != "" | |
| def test_harassment(self): | |
| result = classify_legal_situation_keywords("I'm being harassed at work by my boss") | |
| assert result != "" | |
| def test_no_match(self): | |
| result = classify_legal_situation_keywords("I want to learn about cooking recipes") | |
| assert result == "" or result is None or "none" in result.lower() or result == "other" | |