test: add coverage for server/tools/* and index_service pipeline flow#85
Merged
Merged
Conversation
server/tools/*.py had zero tests, and index_service only had a single parser-failure regression test. Adds tests for search_code, find_symbol, find_usages (including the path reconstruction in get_code_context and the limit/self-match interaction in find_usages), admin, index, and history tools by extracting registered @mcp.tool() functions from a throwaway FastMCP instance. Also covers index_service's incremental skip, force override, stale-entry cleanup, no-symbols cleanup, embedding-failure preservation, and delete-before-upsert ordering. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #78 (partially — see scope note below).
server/tools/*.py(search.py,admin.py,index.py,history.py) had zero tests. Addedtests/tools/with a small helper (tests/tools/conftest.py) that extracts registered@mcp.tool()functions from a throwawayFastMCPinstance so each tool can be exercised directly without going through MCP's request/response plumbing.tests/test_pipeline.pyonly had a single regression test forindex_service(parser failure preserving existing entries). Added tests for the incremental-skip path,forceoverride, stale-entry cleanup, no-symbols-in-file cleanup, embedding-failure preservation, and delete-before-upsert ordering.Notable coverage
search_code,find_symbol— result formatting and empty-result messaging.find_usages— self-match exclusion, snippet windowing, and a test documenting a known limitation called out in the issue: self-matches are filtered out after thelimit-bounded fetch, so results can undercount when the fetched window is dominated by self-matches. This is left as-is (test only, no behavior change) since the issue asked for coverage, not a fix.get_code_context— thesvc.rootpath-reconstruction logic (search.py:196-197), the Qdrant-vs-text-search fallback for locating a symbol, and the GitHub-fetch error path.admin.py/index.py/history.py— success and error-message formatting for all six tools.index_service— incremental skip, force reindex, stale cleanup, empty-symbol cleanup, embedding failure, and delete-before-upsert call ordering.Scope note
Issue #78's body also calls out gaps in
openai/jina/ollamaembedding retry paths andgithub_source's rate-limit retry / >1MB blob fallback. Those aren't addressed here — this PR scopes to the issue title (server/tools/*and theindex_servicepipeline flow). Happy to open a follow-up issue for the remaining embedding/github_source gaps if useful.Test plan
uv run pytest— 254 passeduv run pytest tests/tools tests/test_pipeline.py -q— 48 new tests, all passingruff formatclean🤖 Generated with Claude Code