Skip to content

fix(tests): BotOS integration tests use registry unregister#1669

Merged
MervinPraison merged 2 commits into
mainfrom
fix/tests-botos-use-registry-unregister
May 15, 2026
Merged

fix(tests): BotOS integration tests use registry unregister#1669
MervinPraison merged 2 commits into
mainfrom
fix/tests-botos-use-registry-unregister

Conversation

@MervinPraison
Copy link
Copy Markdown
Owner

@MervinPraison MervinPraison commented May 14, 2026

Replaces removed _custom_platforms dict usage with get_default_bot_registry().unregister() after the bot registry moved to PluginRegistry. Updates unknown-platform assertion to match the current ValueError text.

Made with Cursor

Summary by CodeRabbit

  • Tests
    • Improved cleanup for runtime-registered bot platforms in integration tests to ensure proper unregistering and avoid residual state.
    • Relaxed platform-resolution error matching in tests to use a broader pattern for more robust validation.

Review Change Stack

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings May 14, 2026 18:39
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 261f0c17-53f2-4919-9b25-79c89a87cf56

📥 Commits

Reviewing files that changed from the base of the PR and between b31e14f and 65a51be.

📒 Files selected for processing (1)
  • src/praisonai-agents/tests/unit/test_botos_integration.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/praisonai-agents/tests/unit/test_botos_integration.py

📝 Walkthrough

Walkthrough

Adds a module-private _unregister_bot_platform helper and updates test-class setup/teardown and a multi-platform test to unregister platforms via the bot registry API instead of mutating _custom_platforms; also relaxes an unknown-platform error assertion to match Unknown .*plugin.

Changes

Test Registry Cleanup Migration

Layer / File(s) Summary
Registry cleanup helper
src/praisonai-agents/tests/unit/test_botos_integration.py
New _unregister_bot_platform(name) helper wraps get_default_bot_registry().unregister(name.lower()) for test cleanup.
Apply cleanup helper across test classes and tests
src/praisonai-agents/tests/unit/test_botos_integration.py
TestBotWithMockAdapter, TestBotOSLifecycle, TestRealAgentInBot, TestAgentTeamInBotOS, TestAgentFlowInBotOS, TestPlatformExtensibility, and TestBotOSFromConfig updated to call the helper instead of mutating _custom_platforms. test_from_config_multi_platform imports/cleanup adjusted and unknown-platform assertion relaxed to Unknown .*plugin.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble code and tidy the plot,
A small helper hops, now nothing is caught,
Platforms unregistered, no mapping to trot,
Tests breathe easy — the registry's the spot,
Hooray for clean hops and a neat little knot!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix(tests): BotOS integration tests use registry unregister' accurately describes the main change: replacing internal _custom_platforms dict usage with registry unregister API calls in test cleanup logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/tests-botos-use-registry-unregister

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.

@MervinPraison
Copy link
Copy Markdown
Owner Author

@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first — incorporate their findings.

Review areas:

  1. Bloat check: Are changes minimal and focused? Any unnecessary code or scope creep?
  2. Security: Any hardcoded secrets, unsafe eval/exec, missing input validation?
  3. Performance: Any module-level heavy imports? Hot-path regressions?
  4. Tests: Are tests included? Do they cover the changes adequately?
  5. Backward compat: Any public API changes without deprecation?
  6. Code quality: DRY violations, naming conventions, error handling?
  7. Address reviewer feedback: If Qodo, Coderabbit, or Gemini flagged valid issues, include them in your review
  8. Suggest specific improvements with code examples where possible

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR fixes integration tests that broke when the bot registry was migrated from a plain _custom_platforms dict to PluginRegistry. It introduces a shared _unregister_bot_platform helper and updates the unknown-platform error-match regex to reflect the new ValueError message format.

  • Replaces all _custom_platforms.pop(name, None) teardown calls with get_default_bot_registry().unregister(name) via a new module-level helper, removing the private-dict dependency.
  • Updates test_resolve_unknown_platform_raises to match the new error text (r\"Unknown .*plugin\" instead of \"Unknown platform\"), correctly aligning with PluginRegistry.resolve()'s message.

Confidence Score: 5/5

Safe to merge — the change is confined to test cleanup logic, removes a dependency on a removed private API, and the new error-message regex correctly matches the live PluginRegistry output.

Both the new unregister path and the updated regex are straightforward adaptations to the PluginRegistry migration. The singleton shared between register_platform and _unregister_bot_platform is the same object, so registration and cleanup operate on identical state. No production code is touched.

No files require special attention.

Important Files Changed

Filename Overview
src/praisonai-agents/tests/unit/test_botos_integration.py Replaces removed _custom_platforms dict-mutation cleanup with get_default_bot_registry().unregister() across all test classes, and tightens the unknown-platform error-message regex to match the new PluginRegistry message format.

Sequence Diagram

sequenceDiagram
    participant Test as Test (setup_method)
    participant RP as register_platform()
    participant DR as get_default_bot_registry()
    participant PR as BotPlatformRegistry (singleton)

    Test->>RP: register_platform("mockbot", MockPlatformAdapter)
    RP->>DR: get_default_bot_registry()
    DR-->>RP: BotPlatformRegistry instance
    RP->>PR: registry.register("mockbot", cls)

    Note over Test: teardown_method
    Test->>DR: get_default_bot_registry()
    DR-->>Test: same BotPlatformRegistry instance
    Test->>PR: registry.unregister("mockbot")
    PR-->>Test: True (removed) / False (not found)
Loading

Reviews (2): Last reviewed commit: "fix(tests): add exception handling to _u..." | Re-trigger Greptile

@MervinPraison
Copy link
Copy Markdown
Owner Author

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions

Phase 2: FIX Valid Issues
4. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
5. Push all code fixes directly to THIS branch (do NOT create a new PR)
6. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
7. If all issues are resolved, approve the PR / close the Issue
8. If blocking issues remain, request changes / leave clear action items

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 the integration tests by introducing a _unregister_bot_platform helper function to manage the removal of bot platforms from the registry, replacing direct access to internal state. It also updates the expected error message for unknown platform resolution. The reviewer suggested improving the robustness of the new helper function by wrapping the unregistration logic in a try-except block to prevent cleanup failures from masking primary test errors.

Comment on lines +24 to +28
def _unregister_bot_platform(name: str) -> None:
"""Remove a runtime-registered bot platform (tests only)."""
from praisonai.bots._registry import get_default_bot_registry

get_default_bot_registry().unregister(name.lower())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The unregister method on the registry likely raises a ValueError or KeyError if the platform name is not found (consistent with the resolve method's behavior in the same registry). Since this helper is used in teardown_method and cleanup lambdas where the platform might not have been successfully registered (e.g., if a test fails early or only registers a subset of platforms), it should be made safe to avoid secondary failures during cleanup that could mask the original test failure.

Suggested change
def _unregister_bot_platform(name: str) -> None:
"""Remove a runtime-registered bot platform (tests only)."""
from praisonai.bots._registry import get_default_bot_registry
get_default_bot_registry().unregister(name.lower())
def _unregister_bot_platform(name: str) -> None:
"""Remove a runtime-registered bot platform (tests only)."""
from praisonai.bots._registry import get_default_bot_registry
try:
get_default_bot_registry().unregister(name.lower())
except (KeyError, ValueError):
pass

@praisonai-triage-agent
Copy link
Copy Markdown
Contributor

praisonai-triage-agent Bot commented May 14, 2026

Claude finished @MervinPraison's task —— View job


Final Architecture Review ✅ APPROVED

Todo List:

  • Read AGENTS.md architecture guidelines
  • Review changed files against architecture rules
  • Analyze previous reviewer feedback
  • Implement valid fixes identified by reviewers
  • Push changes to branch
  • Provide final verdict

Architecture Compliance ✅

Phase 1: AGENTS.md Review

  • Protocol-driven: Changes are test-only, no core protocol modifications
  • Backward compatible: No public API changes, only internal test improvements
  • Performance: Zero hot-path impact, test-only cleanup improvements

Issue Resolution ✅

Phase 2: Fixed Valid Issues

  1. Gemini Issue: _unregister_bot_platform lacked exception handling
    • Fixed: Added try/catch for KeyError and ValueError
    • Rationale: Prevents cleanup failures from masking primary test errors
    • Implementation: src/praisonai-agents/tests/unit/test_botos_integration.py:28-31

Phase 3: Final Assessment

Criterion Status Notes
Architecture adherence ✅ Pass Test-only changes, follows SDK patterns
Reviewer feedback addressed ✅ Pass Implemented Gemini's exception handling fix
Code quality ✅ Pass Clean, focused, minimal changes
Security ✅ Pass No security implications
Performance ✅ Pass No performance impact

Summary

This PR successfully modernizes BotOS integration tests by:

  1. Replacing deprecated _custom_platforms dict access with proper get_default_bot_registry().unregister() calls
  2. Updating error message assertions to match current PluginRegistry format
  3. Adding robust exception handling to prevent cleanup failures from masking test errors

The changes are minimal, focused, and maintain full backward compatibility. All valid reviewer concerns have been addressed.

✅ APPROVED - Ready to merge


Modified files: src/praisonai-agents/tests/unit/test_botos_integration.py
Commits: 2 (original fix + exception handling improvement)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/praisonai-agents/tests/unit/test_botos_integration.py (1)

406-407: ⚡ Quick win

Tighten error-match regex to avoid false positives.

r"Unknown .*plugin" is permissive enough to match unrelated messages. Consider matching the unknown platform identifier too.

Proposed assertion tightening
-        with pytest.raises(ValueError, match=r"Unknown .*plugin"):
+        with pytest.raises(ValueError, match=r"Unknown .*plugin.*nonexistent_xyz"):
             resolve_adapter("nonexistent_xyz")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai-agents/tests/unit/test_botos_integration.py` around lines 406 -
407, The test's error regex is too permissive and can match unrelated messages;
update the pytest.raises in the test that calls
resolve_adapter("nonexistent_xyz") to assert the specific unknown identifier is
present (e.g., match "nonexistent_xyz") or use a stricter pattern like r"Unknown
.*plugin: .*nonexistent_xyz" so the failure only passes when the resolver
reports that exact platform (refer to the resolve_adapter call in the test).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/praisonai-agents/tests/unit/test_botos_integration.py`:
- Around line 406-407: The test's error regex is too permissive and can match
unrelated messages; update the pytest.raises in the test that calls
resolve_adapter("nonexistent_xyz") to assert the specific unknown identifier is
present (e.g., match "nonexistent_xyz") or use a stricter pattern like r"Unknown
.*plugin: .*nonexistent_xyz" so the failure only passes when the resolver
reports that exact platform (refer to the resolve_adapter call in the test).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90673625-ece1-478c-896a-2389e4c3a9d5

📥 Commits

Reviewing files that changed from the base of the PR and between c989f2c and b31e14f.

📒 Files selected for processing (1)
  • src/praisonai-agents/tests/unit/test_botos_integration.py

Prevents cleanup failures from masking primary test errors by catching
KeyError/ValueError exceptions during platform unregistration.

Addresses Gemini reviewer feedback.

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants