Skip to content

test: add more tests for search_repository - #181

Merged
phernandez merged 4 commits into
mainfrom
claude/issue-178-20250626_152657
Jun 26, 2025
Merged

phernandez merged 4 commits into
mainfrom
claude/issue-178-20250626_152657

Conversation

@phernandez

Copy link
Copy Markdown
Member

Add tests to get search_repository coverage to 100%

claude Bot and others added 4 commits June 26, 2025 15:39
- Add _prepare_boolean_query method to parse Boolean queries and quote individual terms
- Add _prepare_single_term method to handle single term preparation logic
- Update _prepare_search_term to use new Boolean query processing
- Simplify search method by removing redundant Boolean handling logic
- Add test cases for hyphenated terms with Boolean operators

This fixes the issue where queries like "tier1-test AND unicode" would cause SQL parsing errors
because FTS5 was treating "tier1-test" as a column name instead of a search term.

The fix ensures that:
- Boolean operators (AND, OR, NOT) are preserved
- Terms with special characters (hyphens, dots, etc.) are properly quoted
- Simple terms in Boolean queries remain unquoted for optimal FTS5 performance
- Complex Boolean expressions with parentheses are handled correctly

Fixes #178

Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
- Move import re to top of file instead of inside method
- Simplify Boolean operator regex pattern to avoid nested capture groups  
- Use simple string matching for Boolean operators instead of regex fullmatch
- Simplify parentheses handling to focus on core Boolean parsing
- Fixes test failures for hyphenated terms with Boolean operators

Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
- Add _prepare_parenthetical_term() method to preserve parentheses for grouping
- Add _needs_quoting() helper method for cleaner quoting logic
- Fix parentheses being quoted incorrectly in Boolean expressions
- Ensure queries like "(hello AND world) OR test" work correctly
- Maintain proper quoting for hyphenated terms within parentheses

Fixes failing tests:
- test_boolean_operators_preserved
- test_hyphenated_terms_with_boolean_operators

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive test cases to cover previously untested edge cases:

- Boolean query parsing with empty parts after regex splitting
- Quote escaping in parenthetical terms with double quotes
- Empty input validation for _needs_quoting() method
- Empty input handling for _prepare_single_term() method

These tests target specific lines identified in coverage gaps:
- Line 143: Empty parts in Boolean query parsing
- Lines 190-191: Quote escaping in parenthetical expressions
- Line 207: Empty input validation
- Line 227: Empty term handling

Coverage improved from 28% to 89% for search_repository.py with
all new tests passing and existing functionality preserved.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@phernandez
phernandez merged commit ac9e148 into main Jun 26, 2025
@phernandez
phernandez deleted the claude/issue-178-20250626_152657 branch June 26, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant