@@ -532,3 +532,51 @@ async def test_wildcard_only_search(self, search_repository, search_entity):
532532 # Test whitespace-only search
533533 results_whitespace = await search_repository .search (search_text = " " )
534534 assert isinstance (results_whitespace , list ) # Should not crash
535+
536+ def test_boolean_query_empty_parts_coverage (self , search_repository ):
537+ """Test Boolean query parsing with empty parts (line 143 coverage)."""
538+ # Create queries that will result in empty parts after splitting
539+ result1 = search_repository ._prepare_boolean_query ("hello AND AND world" ) # Double operator
540+ assert "hello" in result1 and "world" in result1
541+
542+ result2 = search_repository ._prepare_boolean_query (" OR test" ) # Leading operator
543+ assert "test" in result2
544+
545+ result3 = search_repository ._prepare_boolean_query ("test OR " ) # Trailing operator
546+ assert "test" in result3
547+
548+ def test_parenthetical_term_quote_escaping (self , search_repository ):
549+ """Test quote escaping in parenthetical terms (lines 190-191 coverage)."""
550+ # Test term with quotes that needs escaping
551+ result = search_repository ._prepare_parenthetical_term ('(say "hello" world)' )
552+ # Should escape quotes by doubling them
553+ assert '""hello""' in result
554+
555+ # Test term with single quotes
556+ result2 = search_repository ._prepare_parenthetical_term ('(it\' s working)' )
557+ assert "it's working" in result2
558+
559+ def test_needs_quoting_empty_input (self , search_repository ):
560+ """Test _needs_quoting with empty inputs (line 207 coverage)."""
561+ # Test empty string
562+ assert search_repository ._needs_quoting ("" ) == False
563+
564+ # Test whitespace-only string
565+ assert search_repository ._needs_quoting (" " ) == False
566+
567+ # Test None-like cases
568+ assert search_repository ._needs_quoting ("\t " ) == False
569+
570+ def test_prepare_single_term_empty_input (self , search_repository ):
571+ """Test _prepare_single_term with empty inputs (line 227 coverage)."""
572+ # Test empty string
573+ result1 = search_repository ._prepare_single_term ("" )
574+ assert result1 == ""
575+
576+ # Test whitespace-only string
577+ result2 = search_repository ._prepare_single_term (" " )
578+ assert result2 == " " # Should return as-is
579+
580+ # Test string that becomes empty after strip
581+ result3 = search_repository ._prepare_single_term ("\t \n " )
582+ assert result3 == "\t \n " # Should return original
0 commit comments