38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import pytest
|
|
from llm.chains import validate_response
|
|
|
|
def test_validate_response_valid():
|
|
"""Test validation with valid response"""
|
|
response = {
|
|
"hasMultipleEscalations": False,
|
|
"customerSentiment": "neutral"
|
|
}
|
|
assert validate_response(response) is True
|
|
|
|
def test_validate_response_missing_field():
|
|
"""Test validation with missing required field"""
|
|
response = {
|
|
"hasMultipleEscalations": False
|
|
}
|
|
assert validate_response(response) is False
|
|
|
|
def test_validate_response_invalid_type():
|
|
"""Test validation with invalid field type"""
|
|
response = {
|
|
"hasMultipleEscalations": "not a boolean",
|
|
"customerSentiment": "neutral"
|
|
}
|
|
assert validate_response(response) is False
|
|
|
|
def test_validate_response_null_sentiment():
|
|
"""Test validation with null sentiment"""
|
|
response = {
|
|
"hasMultipleEscalations": True,
|
|
"customerSentiment": None
|
|
}
|
|
assert validate_response(response) is True
|
|
|
|
def test_validate_response_invalid_structure():
|
|
"""Test validation with invalid JSON structure"""
|
|
response = "not a dictionary"
|
|
assert validate_response(response) is False |