Spaces:
Sleeping
Sleeping
| import pytest | |
| from src.rag.scope_guardian import ScopeGuardian | |
| def test_off_topic_queries_are_detected(message): | |
| assert ScopeGuardian.check_scope(message) == "off_topic" | |
| def test_german_off_topic_redirect_acknowledges_restaurant_subject(): | |
| message = ScopeGuardian.get_redirect_message("off_topic", "de") | |
| assert "Restaurants" in message | |
| assert "kann ich leider nicht beraten" in message | |
| assert "HSG Executive MBA" in message | |
| def test_movie_queries_are_detected_as_off_topic(message): | |
| assert ScopeGuardian.check_scope(message) == "off_topic" | |
| def test_on_topic_queries_remain_allowed(message): | |
| assert ScopeGuardian.check_scope(message) == "on_topic" | |
| def test_programme_travel_context_remains_allowed(message): | |
| assert ScopeGuardian.check_scope(message) == "on_topic" | |
| def test_financial_planning_queries_keep_their_classification(): | |
| assert ScopeGuardian.check_scope("Can you create a payment plan?") == "financial_planning" | |
| def test_aggressive_queries_keep_their_classification(): | |
| assert ScopeGuardian.check_scope("This chatbot is useless") == "aggressive" | |
| def test_redirect_language_fallback_preserves_scope_type(): | |
| message = ScopeGuardian.get_redirect_message("aggressive", "fr") | |
| assert "remain respectful" in message | |
| assert "restaurants" not in message | |