test: add initial backend test suite - #23
Merged
Merged
Conversation
Covers server SSE helpers and endpoints, Pydantic model validation, tool utility functions, and LimitDeps/check_env in _utils. Adds pytest-cov and httpx as dev dependencies. Closes #9
| mock_async_client.get = AsyncMock(return_value=mock_resp) | ||
| return mock_async_client | ||
|
|
||
| def test_returns_vllm_true_when_reachable(self, monkeypatch): |
There was a problem hiding this comment.
monkeypatch parameter is declared but never used in this test
Merged
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.
Adds a pytest suite covering the testable surface of the Python backend.
Coverage (53 tests, 47% overall):
test_server.py— SSE formatting helpers, CORS origins,/api/query,/api/session,/api/healthtest_types.py— Pydantic model validation for all types in_types.pytest_tools.py—build_url_restricted_queryunit tests (I/O-heavy functions excluded)test_utils.py—LimitDepsandcheck_envInfrastructure:
conftest.pysets required env vars and mockstransformersbefore import to avoid HuggingFace downloads in CIpytest-covandhttpxas dev dependenciesNot covered yet:
_graph.pyagent nodes (require a running vLLM instance).Closes #9
Greptile Summary
This PR establishes a solid test foundation for the Python backend with 53 tests achieving 47% coverage. The test suite is well-structured with appropriate mocking strategies to avoid external dependencies (HuggingFace downloads, API calls) during CI runs.
Key additions:
Notable decisions:
conftest.pymocks thetransformersmodule at import time to prevent model downloadssearch_web,search_papers,read_url) intentionally excluded as documented_graph.py) deferred to future work requiring live vLLM instanceThe tests follow Python best practices with clear naming, good documentation, and appropriate use of pytest features.
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: fb76484