-
Notifications
You must be signed in to change notification settings - Fork 0
test: improve coverage for models and toolset modules (76% → 87%) #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Remove the _matches_filter method from StackOneToolSet as it was never called in the source code (only used in tests). This reduces code complexity and improves test coverage percentage. The existing _filter_by_provider and _filter_by_action methods provide equivalent functionality and are actually used in fetch_tools.
Add comprehensive tests for previously uncovered code paths: models.py (78% -> 95%): - validate_method unsupported HTTP method error - ExecuteConfig validation - Parameter location handling (PATH, QUERY, BODY) - HTTP error handling (JSON and text response bodies) - RequestError handling - Non-dict response wrapping - OpenAI conversion (enum, array, object, non-dict properties) - LangChain conversion (number, integer, boolean types) - Async _arun method - Tools container iteration and account ID methods toolset.py (52% -> 77%): - _StackOneRpcTool execution (basic, JSON string, payloads) - Header handling (Authorization stripping, None value skipping) - Argument parsing edge cases Overall coverage improved from 76% to 87%.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves test coverage from 76% to 87% by removing unused code and adding comprehensive tests for the models.py and toolset.py modules.
- Removed the unused
_matches_filtermethod fromStackOneToolSetand its associated tests - Added extensive test coverage for
StackOneToolexecution, parameter handling, error scenarios, and framework conversions - Added comprehensive tests for
_StackOneRpcToolRPC execution with various payload types and edge cases
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| stackone_ai/toolset.py | Removed unused _matches_filter method (28 lines) |
| tests/test_toolset.py | Removed tests for deleted _matches_filter method (29 lines) |
| tests/test_tool_calling.py | Added 199 lines of comprehensive tests for _StackOneRpcTool including execution, header handling, and argument parsing |
| tests/test_models.py | Added 536 lines of tests covering validation, execution edge cases, error handling, OpenAI/LangChain conversions, and Tools container functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 4 files
glebedel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| self.base_url = base_url or DEFAULT_BASE_URL | ||
| self._account_ids: list[str] = [] | ||
|
|
||
| def _matches_filter(self, tool_name: str, filter_pattern: str | list[str]) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this not used for glob filtering at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use _filter_by_action function instead
Summary
_matches_filtermethod fromStackOneToolSetmodels.pyandtoolset.pymodulesChanges
Code cleanup
_matches_filtermethod which was defined but never called in source codeNew tests for
models.py(78% → 95%)validate_methodunsupported HTTP method errorExecuteConfigvalidationRequestErrorhandling_arunmethodToolscontainer iteration and account ID methodsNew tests for
toolset.py(52% → 77%)_StackOneRpcToolexecution (basic, JSON string, payloads)Future work
integrations/langgraph.py(currently 0% coverage)toolset.pyare MCP communication code (_run_async,_fetch_mcp_tools) which are mocked in testsTest plan
Summary by cubic
Improved test coverage from 76% to 87% by adding thorough tests across models and toolset, and removing an unused filter helper for cleaner code.
Refactors
Tests
Written for commit da130b2. Summary will update automatically on new commits.