test(server): add integration tests for MCP tool functions#6
Closed
clawtom wants to merge 1 commit intoraphasouthall:mainfrom
Closed
test(server): add integration tests for MCP tool functions#6clawtom wants to merge 1 commit intoraphasouthall:mainfrom
clawtom wants to merge 1 commit intoraphasouthall:mainfrom
Conversation
Closes raphasouthall#5. Adds tests/test_server_integration.py covering the three tool functions identified in the issue: vault_stats, vault_prediction_errors, and vault_search. Strategy: each test uses a `server_db` fixture that creates an initialised SQLite file in a temp directory and patches `neurostack.schema.DB_PATH` via pytest's monkeypatch. Tools import DB_PATH lazily (inside each function), so the patch is visible when the tool runs — no Ollama or real vault required. Tests cover: - vault_stats: valid JSON, required keys present, counts match inserted data, coverage strings are formatted as percentages - vault_prediction_errors: valid JSON, required keys, empty when no errors, surfaces inserted errors, error_type filter, resolve clears errors - vault_search (mode=keyword): valid JSON, finds relevant note by content, result items have required fields, no results for nonsense query, hybrid mode falls back gracefully when embedding service is unavailable Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Author
|
Closing in favour of #7 which has a more complete commit message and test coverage. Apologies for the duplicate — a previous session submitted a partial version before completing. |
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.
Closes #5.
Adds
tests/test_server_integration.pycovering the three tool functions from the issue:vault_stats,vault_prediction_errors, andvault_search.Approach
Each test uses a
server_dbfixture that:tmp_pathtemp directoryneurostack.schema.DB_PATHvia pytestmonkeypatchServer tools import
DB_PATHlazily (inside each function viafrom .schema import DB_PATH), so the patch is visible at call time — no Ollama, no real vault, no network required.Coverage
vault_stats: valid JSON; required keys present (notes,chunks,embedded,embedding_coverage, etc.); counts match inserted test data; coverage values formatted as percentages.vault_prediction_errors: valid JSON; required keys (total_flagged_notes,showing,errors); empty when no errors; surfaces inserted errors;error_typefilter works;resolveclears errors.vault_search(mode=keyword): valid JSON; finds relevant note by content; result items have required fields (path,title,section,score,snippet); no results for nonsense query; hybrid mode falls back gracefully when embedding service is unavailable.🤖 Generated with Claude Code