from shell_history_search.core.search import SearchResult class TestSearchResult: def test_search_result_creation(self): result = SearchResult( command="ls -la", shell_type="bash", timestamp=1234567890, similarity=0.95, command_id=1 ) assert result.command == "ls -la" assert result.similarity == 0.95 def test_search_result_sorting(self): results = [ SearchResult("cmd1", "bash", 123, 0.5, 1), SearchResult("cmd2", "bash", 124, 0.9, 2), SearchResult("cmd3", "bash", 125, 0.7, 3), ] sorted_results = sorted(results, key=lambda r: r.similarity, reverse=True) assert sorted_results[0].similarity >= sorted_results[1].similarity >= sorted_results[2].similarity