Skip to content

chore(agents): branch on expected_type in agent tool tests#2575

Merged
haakonvt merged 2 commits into
masterfrom
test/agent-tools-branch-on-expected-type
Apr 18, 2026
Merged

chore(agents): branch on expected_type in agent tool tests#2575
haakonvt merged 2 commits into
masterfrom
test/agent-tools-branch-on-expected-type

Conversation

@ks93
Copy link
Copy Markdown
Contributor

@ks93 ks93 commented Apr 17, 2026

Summary

  • Test branches keyed off isinstance(loaded_tool, ...), the object under test, so a loader regression returning the wrong subtype could silently skip assertion blocks and still pass.
  • Switched the branch conditions to expected_type is ... (the trusted parametrize input) and kept the subtype check inside as a real assert isinstance(...), so a wrong subtype fails loudly.
  • Applied across TestAgentToolLoad, TestAgentToolDump, and TestAgentToolUpsert.

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

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.
@ks93 ks93 marked this pull request as ready for review April 17, 2026 23:51
@ks93 ks93 requested review from a team as code owners April 17, 2026 23:51
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/tests_unit/test_data_classes/test_agents/test_agent_tools.py Outdated
Comment thread tests/tests_unit/test_data_classes/test_agents/test_agent_tools.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.74%. Comparing base (46babc5) to head (a4924df).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../test_data_classes/test_agents/test_agent_tools.py 90.90% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
.../test_data_classes/test_agents/test_agent_tools.py 98.55% <90.90%> (+0.11%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@haakonvt haakonvt changed the title test(agents): branch on expected_type in agent tool tests chore(agents): branch on expected_type in agent tool tests Apr 18, 2026
Copy link
Copy Markdown
Contributor

@haakonvt haakonvt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦄

@haakonvt haakonvt added this pull request to the merge queue Apr 18, 2026
@haakonvt haakonvt self-assigned this Apr 18, 2026
@haakonvt haakonvt added risk-review-ongoing Risk review is in progress waiting-for-team Waiting for the submitter or reviewer of the PR to take an action labels Apr 18, 2026
Merged via the queue into master with commit 9360f2e Apr 18, 2026
22 checks passed
@haakonvt haakonvt deleted the test/agent-tools-branch-on-expected-type branch April 18, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk-review-ongoing Risk review is in progress waiting-for-team Waiting for the submitter or reviewer of the PR to take an action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants