Spaces:
Sleeping
Sleeping
File size: 2,154 Bytes
135f0d6 159faf0 135f0d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
"""
Test basic guardrails system functionality.
"""
from src.guardrails import GuardrailsSystem
def test_guardrails_system_initialization():
"""Test that guardrails system initializes properly."""
system = GuardrailsSystem()
assert system is not None
assert system.response_validator is not None
assert system.content_filter is not None
assert system.quality_metrics is not None
assert system.source_attributor is not None
assert system.error_handler is not None
def test_guardrails_system_basic_validation():
"""Test basic response validation through guardrails system."""
system = GuardrailsSystem()
# Test data
response = "According to our employee handbook, remote work is allowed " "with manager approval."
query = "What is our remote work policy?"
sources = [
{
"content": "Remote work is permitted with proper approval and guidelines.",
"metadata": {"filename": "employee_handbook.md", "section": "Remote Work"},
"relevance_score": 0.9,
}
]
# Validate response
result = system.validate_response(response, query, sources)
# Basic assertions
assert result is not None
assert hasattr(result, "is_approved")
assert hasattr(result, "confidence_score")
assert hasattr(result, "validation_result")
assert hasattr(result, "safety_result")
assert hasattr(result, "quality_score")
assert hasattr(result, "citations")
# Should have processed successfully
assert result.processing_time > 0
assert len(result.components_used) > 0
def test_guardrails_system_health():
"""Test guardrails system health check."""
system = GuardrailsSystem()
health = system.get_system_health()
assert health is not None
assert "status" in health
assert "components" in health
assert "error_statistics" in health
assert "configuration" in health
if __name__ == "__main__":
# Run basic tests
test_guardrails_system_initialization()
test_guardrails_system_basic_validation()
test_guardrails_system_health()
print("All basic guardrails tests passed!")
|