#!/usr/bin/env python3 """ Test script to verify that similarity threshold is properly handled """ import json from src.schemas.search import SearchRequest def test_threshold_handling(): """Test that threshold values are properly handled in the schema""" # Test with threshold = 0 test_data_zero = { "query": "test query", "threshold": 0.0, "limit": 10 } request_zero = SearchRequest(**test_data_zero) print(f"Threshold 0.0 test: {request_zero.threshold}") assert request_zero.threshold == 0.0, f"Expected 0.0, got {request_zero.threshold}" # Test with threshold = 0.5 test_data_half = { "query": "test query", "threshold": 0.5, "limit": 10 } request_half = SearchRequest(**test_data_half) print(f"Threshold 0.5 test: {request_half.threshold}") assert request_half.threshold == 0.5, f"Expected 0.5, got {request_half.threshold}" # Test with threshold = 1.0 test_data_one = { "query": "test query", "threshold": 1.0, "limit": 10 } request_one = SearchRequest(**test_data_one) print(f"Threshold 1.0 test: {request_one.threshold}") assert request_one.threshold == 1.0, f"Expected 1.0, got {request_one.threshold}" print("All threshold tests passed!") if __name__ == "__main__": test_threshold_handling()