sweep
sweep copied to clipboard
Sweep: Add tests for context agent
Description
This pull request introduces unit tests for the context agent within the SweepAI project, specifically targeting the context_pruning.py module. It aims to ensure the reliability and correctness of the context agent's functionality, particularly in handling function calls and retrieving relevant context for given queries.
Summary
- Added
MagicMockandpatchfromunittest.mockto mock dependencies and function calls during testing. - Implemented a test for
handle_function_callto verify that it correctly processes a function call, modifies the repository context manager as expected, and asserts the success of the operation. - Implemented a test for
get_relevant_contextto ensure it accurately retrieves and returns the relevant context snippets for a given query by mocking thecontext_dfsfunction and asserting the correct snippets are returned. - These tests are crucial for maintaining the integrity of the context agent's operations, especially when handling complex queries and function calls within the
sweepai/core/context_pruning.pymodule.
Fixes #3489.
🎉 Latest improvements to Sweep:
- New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
- Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
- Use the GitHub issues extension for creating Sweep issues directly from your editor.
💡 To get Sweep to edit this pull request, you can:
- Comment below, and Sweep can edit the entire PR
- Comment on a file, Sweep will only modify the commented file
- Edit the original issue to get Sweep to recreate the PR from scratch
This is an automated message generated by Sweep AI.
Rollback Files For Sweep
- [ ] Rollback changes to sweepai/core/context_pruning.py
This is an automated message generated by Sweep AI.
Apply Sweep Rules to your PR?
- [ ] Apply: We should use loguru for error logging. If the log is inside an exception, use logger.exception to add tracebacks, where logger is imported from loguru. Use f-strings for string formatting in logger calls (e.g. logger.info(f'Hello {name}') instead of logger.info('Hello {name}', name=name)).
- [ ] Apply: There should be no debug log or print statements in production code.
- [ ] Apply: All functions should have parameters and output annotated with type hints. Use list, tuple and dict instead of typing.List, typing.Tuple and typing.dict.
- [ ] Apply: Leftover TODOs in the code should be handled.
- [ ] Apply: All new business logic should have corresponding unit tests in the same directory. For example, sweepai/api_test.py tests sweepai/api.py. Use unittest and unittest.mock as required.
- [ ] Apply: Any clearly inefficient or repeated code should be optimized or refactored.
- [ ] Apply: Remove any comments before code that are obvious. For example
# this prints hello world; print('hello world').
This is an automated message generated by Sweep AI.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| sweep-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 8, 2024 5:52am |