chore(agents): branch on expected_type in agent tool tests#2575
Merged
Conversation
Tests were branching on isinstance(loaded_tool, ...), which is the object under test. A loader regression returning the wrong subtype could silently skip entire assertion blocks and still pass. Branching on the parametrized expected_type keeps the isinstance check as a real assertion.
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors agent tool unit tests to use the expected_type parameter for conditional logic and adds explicit type assertions. Feedback suggests adding a base isinstance check in the dump and upsert tests to ensure the loader returns the correct subtype consistently across the test suite.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2575 +/- ##
==========================================
- Coverage 92.76% 92.74% -0.03%
==========================================
Files 480 480
Lines 48441 48446 +5
==========================================
- Hits 44936 44930 -6
- Misses 3505 3516 +11
🚀 New features to boost your workflow:
|
Mirrors the pattern already used by test_agent_tool_load_returns_correct_subtype, so a loader regression returning a wrong subtype fails loudly here instead of relying on _type string equality alone.
Merged
1 task
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
isinstance(loaded_tool, ...), the object under test, so a loader regression returning the wrong subtype could silently skip assertion blocks and still pass.expected_type is ...(the trusted parametrize input) and kept the subtype check inside as a realassert isinstance(...), so a wrong subtype fails loudly.TestAgentToolLoad,TestAgentToolDump, andTestAgentToolUpsert.Follows review feedback from @haakonvt on #2569.
Test plan
poetry run pytest tests/tests_unit/test_data_classes/test_agents/test_agent_tools.py, 18 passed