[PR #28967] feat: complete test script of plugin manager #32258

Closed
opened 2026-02-21 20:51:03 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/28967

State: closed
Merged: Yes


feat: complete test script of plugin manager

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

This PR implements a comprehensive test suite for the Plugin Manager (PluginInstaller class) with 61 test cases covering all core functionalities.

Fixes

Closes https://github.com/langgenius/dify/issues/28966

What's Included

Test Coverage:

  • Plugin Discovery (5 tests): List plugins, fetch by identifier, pagination, empty results
  • Plugin Loading (7 tests): Upload packages, install from identifiers, uninstall, upgrade
  • Plugin Validation (7 tests): Manifest validation, version/author/name format validation, README fetching
  • Version Compatibility (5 tests): Semantic versioning, minimum Dify version checks, version comparison
  • Dependency Resolution (6 tests): Bundle dependencies, missing dependencies, dependency chains, tool existence
  • Task Management (4 tests): Fetch/delete installation tasks and task items
  • Error Handling (4 tests): Not found, bad request, internal server errors, HTTP errors
  • Category Detection (3 tests): Tool, Model, Extension category auto-detection
  • Resource Requirements (6 tests): Memory, tool/model/storage/endpoint/node permissions
  • Installation Sources (4 tests): Marketplace, GitHub, Package, Remote sources
  • Bundle Operations (4 tests): Marketplace/GitHub/Package dependencies, mixed dependencies
  • Task Status Transitions (4 tests): Pending, Running, Success, Failed statuses
  • I18n Support (2 tests): Multilingual descriptions/labels, README language variants

Code Quality:

  • All 61 tests passing (100% success rate)
  • Ruff linting passed with no errors
  • Follows TDD principles with Arrange-Act-Assert pattern
  • Comprehensive docstrings and inline comments for better understanding
  • Strong type hints throughout
  • Proper mocking with unittest.mock

Testing

# Run the test suite
uv run --project api pytest api/tests/unit_tests/core/plugin/test_plugin_manager.py -v

# Run linting
uv run --project api ruff check api/tests/unit_tests/core/plugin/test_plugin_manager.py

Test Results:

61 passed, 1 warning in ~40s
All ruff checks passed!

Screenshots

Not applicable - this is a backend test implementation with no UI changes.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Contribution by Gittensor, learn more at https://gittensor.io/

**Original Pull Request:** https://github.com/langgenius/dify/pull/28967 **State:** closed **Merged:** Yes --- # feat: complete test script of plugin manager > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary This PR implements a comprehensive test suite for the Plugin Manager (`PluginInstaller` class) with 61 test cases covering all core functionalities. ### Fixes Closes https://github.com/langgenius/dify/issues/28966 ### What's Included **Test Coverage:** - **Plugin Discovery** (5 tests): List plugins, fetch by identifier, pagination, empty results - **Plugin Loading** (7 tests): Upload packages, install from identifiers, uninstall, upgrade - **Plugin Validation** (7 tests): Manifest validation, version/author/name format validation, README fetching - **Version Compatibility** (5 tests): Semantic versioning, minimum Dify version checks, version comparison - **Dependency Resolution** (6 tests): Bundle dependencies, missing dependencies, dependency chains, tool existence - **Task Management** (4 tests): Fetch/delete installation tasks and task items - **Error Handling** (4 tests): Not found, bad request, internal server errors, HTTP errors - **Category Detection** (3 tests): Tool, Model, Extension category auto-detection - **Resource Requirements** (6 tests): Memory, tool/model/storage/endpoint/node permissions - **Installation Sources** (4 tests): Marketplace, GitHub, Package, Remote sources - **Bundle Operations** (4 tests): Marketplace/GitHub/Package dependencies, mixed dependencies - **Task Status Transitions** (4 tests): Pending, Running, Success, Failed statuses - **I18n Support** (2 tests): Multilingual descriptions/labels, README language variants **Code Quality:** - ✅ All 61 tests passing (100% success rate) - ✅ Ruff linting passed with no errors - ✅ Follows TDD principles with Arrange-Act-Assert pattern - ✅ Comprehensive docstrings and inline comments for better understanding - ✅ Strong type hints throughout - ✅ Proper mocking with `unittest.mock` ### Testing ```bash # Run the test suite uv run --project api pytest api/tests/unit_tests/core/plugin/test_plugin_manager.py -v # Run linting uv run --project api ruff check api/tests/unit_tests/core/plugin/test_plugin_manager.py ``` **Test Results:** ``` 61 passed, 1 warning in ~40s All ruff checks passed! ``` ## Screenshots Not applicable - this is a backend test implementation with no UI changes. ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods Contribution by Gittensor, learn more at https://gittensor.io/
yindo added the pull-request label 2026-02-21 20:51:03 -05:00
yindo closed this issue 2026-02-21 20:51:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32258