test: improve coverage for models and toolset modules (76% → 87%)#67
Merged
test: improve coverage for models and toolset modules (76% → 87%)#67
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%.
Contributor
There was a problem hiding this comment.
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.
glebedel
approved these changes
Dec 22, 2025
| 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: |
Contributor
There was a problem hiding this comment.
is this not used for glob filtering at all?
Contributor
Author
There was a problem hiding this comment.
we use _filter_by_action function instead
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
_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.