HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.32k stars 605 forks source link

🐛 修复插件商店检查插件更新问题 #1597

Closed AkashiCoin closed 2 weeks ago

AkashiCoin commented 2 weeks ago

Sourcery的总结

修复插件更新检查逻辑,并通过添加新的测试用例和重构插件加载方法来增强测试覆盖率。引入处理不存在插件的测试,并更新现有测试以使用实际的插件内容。

新功能:

错误修复:

增强:

测试:

Original summary in English ## Summary by Sourcery Fix plugin update check logic and enhance test coverage by adding new test cases and refactoring plugin loading methods. Introduce tests for handling non-existent plugins and update existing tests to use actual plugin content. New Features: - Introduce a new test case to handle scenarios where a plugin does not exist, ensuring appropriate messages are sent when attempting to add, update, or search for non-existent plugins. Bug Fixes: - Fix the logic in the version check function to correctly identify when a plugin update is available. Enhancements: - Refactor the method for retrieving loaded plugins into a separate asynchronous function `get_loaded_plugins` to improve code modularity and reuse. - Update test cases to use actual content bytes for plugin files instead of empty byte strings, ensuring more realistic test scenarios. Tests: - Add new test files for plugins `github_sub`, `search_image`, and `jitang` to provide metadata and usage information, enhancing the test coverage for these plugins.
sourcery-ai[bot] commented 2 weeks ago

审核指南由 Sourcery 提供

此拉取请求修复了插件商店中检查插件更新的问题。更改主要集中在改进更新检查逻辑、增强测试覆盖率以及重构一些现有代码以提高可维护性。

文件级更改

更改 详情 文件
修复插件更新检查逻辑
  • 修改了 check_version_is_new 方法以正确识别插件是否是最新的
  • 更新了 version_check 方法以反映新的逻辑
  • 为插件已经是最新的情况添加了新的测试用例
zhenxun/builtin_plugins/plugin_store/data_source.py
改进插件商店功能的测试覆盖率
  • 为更新插件添加了新的测试用例,包括插件已经是最新的情况
  • 实现了处理不存在插件的测试
  • 创建了辅助函数 get_content_bytes 用于加载测试数据
tests/builtin_plugins/plugin_store/test_plugin_store.py
重构代码以提高可维护性
  • 引入了新方法 get_loaded_plugins 以集中检索已加载插件的逻辑
  • 更新了现有方法以使用新的 get_loaded_plugins 方法
zhenxun/builtin_plugins/plugin_store/data_source.py
添加用于测试的示例插件文件
  • 为 'github_sub'、'search_image' 和 'jitang' 插件创建了示例文件
tests/content/plugin_store/github_sub.py
tests/content/plugin_store/search_image.py
tests/content/plugin_store/jitang.py

提示 - 通过在拉取请求中评论 `@sourcery-ai review` 来触发新的 Sourcery 审核。 - 通过直接回复审核评论继续与 Sourcery 的讨论。 - 您可以随时通过访问您的[仪表板](https://app.sourcery.ai)更改审核设置: - 启用或禁用 Sourcery 生成的拉取请求摘要或审核指南; - 更改审核语言; - 如果您有任何问题或反馈,您可以随时[联系我们](mailto:support@sourcery.ai)。
Original review guide in English ## Reviewer's Guide by Sourcery This pull request fixes an issue with checking for plugin updates in the plugin store. The changes primarily focus on improving the update checking logic, enhancing test coverage, and refactoring some existing code for better maintainability. ### File-Level Changes | Change | Details | Files | | ------ | ------- | ----- | | Fixed plugin update check logic |
  • Modified the check_version_is_new method to correctly identify when a plugin is up-to-date
  • Updated the version_check method to reflect the new logic
  • Added a new test case for when a plugin is already up-to-date
| `zhenxun/builtin_plugins/plugin_store/data_source.py` | | Improved test coverage for plugin store functionality |
  • Added new test cases for updating plugins, including when a plugin is already up-to-date
  • Implemented tests for handling non-existent plugins
  • Created helper function get_content_bytes for loading test data
| `tests/builtin_plugins/plugin_store/test_plugin_store.py` | | Refactored code for better maintainability |
  • Introduced a new method get_loaded_plugins to centralize the logic for retrieving loaded plugins
  • Updated existing methods to use the new get_loaded_plugins method
| `zhenxun/builtin_plugins/plugin_store/data_source.py` | | Added sample plugin files for testing |
  • Created sample files for 'github_sub', 'search_image', and 'jitang' plugins
| `tests/content/plugin_store/github_sub.py`
`tests/content/plugin_store/search_image.py`
`tests/content/plugin_store/jitang.py` | ---
Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.