Skip to content

fix(tests): make test_tool_v0 mock import-order independent#1269

Merged
asclearuc merged 1 commit into
developfrom
fix/test-tool-v0
Jun 13, 2026
Merged

fix(tests): make test_tool_v0 mock import-order independent#1269
asclearuc merged 1 commit into
developfrom
fix/test-tool-v0

Conversation

@asclearuc

@asclearuc asclearuc commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

test_tool_v0.py only installed its post_with_retry stub when ai.common.utils wasn't already imported. When a prior test on the same pytest worker imported the real module first, tool_v0 kept the real post_with_retry and made live api.v0.dev calls → 401, failing 7 TestGenerateUi tests under the full suite (passes in isolation).

Rebind post_with_retry and normalize_tool_input on the loaded module after import — same pattern the test already uses for warning — so the stubbing is robust regardless of import order.

Testing

  • Repro (test_config_utils.py then test_tool_v0.py): 7 failed → all pass.
  • test_tool_v0 in isolation: still passes.
  • Full ./builder test: green.

Closes #1268

Summary by CodeRabbit

  • Tests
    • Improved test mocking consistency to ensure reliable behavior across the test suite.

## Summary

`test_tool_v0.py` only installed its `post_with_retry` stub when
`ai.common.utils` wasn't already imported. When a prior test on the same pytest
worker imported the real module first, `tool_v0` kept the real `post_with_retry`
and made live `api.v0.dev` calls → `401`, failing 7 `TestGenerateUi` tests under
the full suite (passes in isolation).

Rebind `post_with_retry` and `normalize_tool_input` on the loaded module after
import — same pattern the test already uses for `warning` — so the stubbing is
robust regardless of import order.

## Testing

- Repro (`test_config_utils.py` then `test_tool_v0.py`): 7 failed → all pass.
- `test_tool_v0` in isolation: still passes.
- Full `./builder test`: green.

Closes #1268
@github-actions github-actions Bot added the module:nodes Python pipeline nodes label Jun 13, 2026
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5edb8136-52ec-40fd-a552-d72f92c4bca1

📥 Commits

Reviewing files that changed from the base of the PR and between ea996d1 and 026941b.

📒 Files selected for processing (1)
  • nodes/test/test_tool_v0.py

📝 Walkthrough

Walkthrough

The test module strengthens its import stubbing by rebinding three functions—warning, post_with_retry, and normalize_tool_input—on the loaded tool_v0.IInstance module to local mock implementations after import, ensuring consistent mocked behavior regardless of test execution order.

Changes

Test mock rebinding for import-order resilience

Layer / File(s) Summary
Mock stub rebinding for test isolation
nodes/test/test_tool_v0.py
Post-import rebinding of warning, post_with_retry, and normalize_tool_input stubs on the loaded tool_v0 module eliminates test flakiness by guaranteeing deterministic mock behavior across varying import orders and preventing unintended real network calls.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A test that flickers with import's whim,
Now bound to stubs, its mocks held trim,
No matter what order the tests may run,
The mocks stand firm—this rabbit's done! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing test_tool_v0 to be independent of import order by improving mock handling.
Linked Issues check ✅ Passed The changes directly address all objectives from #1268: rebinding post_with_retry and normalize_tool_input eliminates import-order dependency and prevents real API calls.
Out of Scope Changes check ✅ Passed All changes are narrowly focused on fixing the mock import-order issue in test_tool_v0.py with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-tool-v0

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID. Do not edit or delete.

@asclearuc asclearuc enabled auto-merge (squash) June 13, 2026 07:43
@asclearuc asclearuc merged commit e3ae76b into develop Jun 13, 2026
22 checks passed
@asclearuc asclearuc deleted the fix/test-tool-v0 branch June 13, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: test_tool_v0 makes real api.v0.dev calls under the full suite

2 participants