Skip to content

feat(messages): unify configurable prompts for setu and fortune#22

Merged
FlanChanXwO merged 14 commits into
masterfrom
fix-configurable-messages-setu-fortune
May 18, 2026
Merged

feat(messages): unify configurable prompts for setu and fortune#22
FlanChanXwO merged 14 commits into
masterfrom
fix-configurable-messages-setu-fortune

Conversation

@FlanChanXwO
Copy link
Copy Markdown
Owner

@FlanChanXwO FlanChanXwO commented May 17, 2026

Summary

  • make Setu and Fortune user-facing prompts configuration-driven via entries
  • add enable/text controls for missing prompt branches (including )
  • add placeholder-aware message resolver for runtime formatting
  • remove hardcoded empty-result notice from Setu use case and resolve it in command layer
  • wire Fortune command feedback/failure strings into shared message config keys

Config/Schema updates

  • expanded under with Setu and Fortune prompt keys
  • extended models with corresponding fields

Tests

  • added
  • added
  • updated image sender/config model tests for toggle behavior and placeholders
  • executed:
    • .......... [100%]
      10 passed in 0.06s
    • ......... [100%]
      9 passed in 0.03s

Summary by Sourcery

在可配置的消息 schema 下统一 Setu 和 Fortune 面向用户的消息,实现支持占位符解析和命令层回退机制。

新功能:

  • 引入通用的消息文本配置模型,为 Setu 和 Fortune 的提示提供启用开关,并新增限流、错误以及 Fortune 管理反馈等键值。

改进:

  • 在配置对象上新增集中式消息解析器,用于处理基于键的查找、启用开关控制以及动态运行时消息的占位符替换。
  • 更新 Setu 和 Fortune 的命令处理器以及图片发送器,使其使用基于配置的消息而非硬编码字符串,包括空结果提示和发送失败通知。

测试:

  • 扩展配置模型测试,用于覆盖默认启用标志以及支持占位符的消息解析语义。
  • 为图片发送器添加测试,验证其是否遵从消息开关和已配置模板。
  • 为 Fortune 命令的消息解析以及在配置中关闭消息时的回退行为添加测试。
  • 添加 Setu 使用场景测试,以确保空结果不再携带硬编码提示文案。
Original summary in English

Summary by Sourcery

Unify Setu and Fortune user-facing messages under a configurable messages schema with placeholder-aware resolution and command-layer fallbacks.

New Features:

  • Introduce a generic message text config model with enable flags for Setu and Fortune prompts, including new keys for rate limiting, errors, and fortune admin feedback.

Enhancements:

  • Add a centralized message resolver on the config object to handle key-based lookup, enable toggles, and placeholder substitution for dynamic runtime messages.
  • Update Setu and Fortune command handlers and the image sender to consume configuration-driven messages instead of hardcoded strings, including empty-result and send-failure notices.

Tests:

  • Extend config model tests to cover default enabled flags and placeholder-aware message resolution semantics.
  • Add tests for image sender behavior respecting message toggles and configured templates.
  • Add tests for Fortune command message resolution and fallback behavior when messages are disabled in config.
  • Add a Setu use case test to ensure empty results no longer carry hardcoded notices.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 17, 2026

审阅者指南

通过共享的消息模型和运行时解析器,使 Setu 和 Fortune 面向用户的提示变为配置驱动;新增启用/禁用行为和占位符替换,并更新 Setu/Fortune 命令处理器以及图片发送行为,以使用这些可配置消息并提供合理的回退,同时加入相应测试和 schema 更新。

Setu 消息解析与发送的序列图

sequenceDiagram
    actor User
    participant SetuCommand
    participant Config as ConfigObject
    participant Messages as MessagesConfig
    participant Event as AstrMessageEvent

    User->>SetuCommand: get_random_picture
    SetuCommand->>SetuCommand: _rate_limiter.acquire
    alt [rate limited]
        SetuCommand->>SetuCommand: _message rate_limited
        SetuCommand->>Config: get_config
        opt [config has resolve_message]
            SetuCommand->>Config: resolve_message rate_limited
            Config->>Messages: lookup messages.rate_limited
            Messages-->>Config: MessageTextConfig
            Config-->>SetuCommand: resolved text
        end
        SetuCommand->>Event: plain_result(text)
    else [not rate limited]
        SetuCommand->>SetuCommand: _fetch_and_send_images
        SetuCommand->>SetuCommand: _message fetching
        SetuCommand->>Config: get_config
        Config-->>SetuCommand: use resolve_message or defaults
        SetuCommand->>Event: plain_result(fetching message)
        Note over SetuCommand: image fetching and sending ...
    end
Loading

resolve_message 支持占位符查询的流程图

flowchart TD
    A[resolve_message key, kwargs] --> B{key in
fetching/found/send_failed?}
    B -- Yes --> C{corresponding
msg_*_enabled?}
    C -- No --> Z[return None]
    C -- Yes --> D[load msg_*_text]
    B -- No --> E[getattr messages.key]
    E --> F{item exists and
enabled?}
    F -- No --> Z
    F -- Yes --> G[read item.text]
    D --> H[set result = text]
    G --> H
    H --> I{any kwargs?}
    I -- No --> J[return result]
    I -- Yes --> K[for each k,v in kwargs:
replace k with v]
    K --> J
Loading

文件级变更

Change Details Files
引入通用且可切换的消息配置模型,并在插件配置上增加集中式消息解析器,然后将所有 Setu/Fortune 以及发送流程接入它(带占位符替换)。
  • 扩展 MessagesSendFailedConfig,加入 enabled 标志,并新增可复用的 MessageTextConfig 模型,包含 enabled/text 字段。
  • 扩展 MessagesConfig,以包含通用的 Setu 和 Fortune 消息键(限流、配置未加载、数量校验、获取错误、无/空结果、R18 docx 失败以及多个 fortune-* 状态/错误消息),并使用带占位符的默认值。
  • 新增 config.msg_send_failed_enabled 属性以及 resolve_message(key, **kwargs) 帮助方法:当特定消息或其 enabled 标志缺失/为 false 时返回 None,并执行简单的 str.replace 占位符替换。
  • 更新 sample_config_dict 测试夹具,使 messages.send_failed 现在默认包含 enabled=True。
src/shared/config/models.py
tests/shared/test_config_models.py
tests/conftest.py
重构 Setu 命令处理器,使其在所有面向用户的文本中使用共享的消息解析器,包括限流、配置错误、数量校验、获取错误和无结果行为,从 Setu 用例中移除硬编码提示。
  • 在 get_random_picture、_handle_random_picture_internal、setu_command、_handle_setu_command_internal 以及相关异常路径中,将硬编码的 plain_result 字符串替换为使用新消息键和占位符的 self._message(key, **kwargs) 调用。
  • 在 _fetch_and_send_images 中,在执行图片获取之前发出可配置的 “fetching” 消息(若启用)。
  • 当 Setu 用例返回空 payload 时,构造 tags_info,并解析可配置的 no_result 消息,而不是使用硬编码字符串。
  • 在 Setu 命令处理器上新增 _message 帮助方法,优先调用 config.resolve_message,并在失败时回退到带占位符插值的本地 defaults 字典。
  • 修改 LLM 的 _llm_get_setu_handler,使其使用 config_not_loaded 和 fetch_failed 键,而不是硬编码字符串。
  • 更新 GetSetuImagesUseCase.execute,使其返回不携带提示的 SetuImagesResult(payload=None),将呈现责任留给命令层。
  • 新增一个 Setu 用例测试,以断言空结果不携带硬编码提示。
src/infrastructure/astrbot/commands/setu.py
src/application/setu/get_images.py
tests/application/test_setu_use_case.py
重构 Fortune 命令处理器(包括 LLM 工具),使其在所有反馈和错误消息中使用共享的消息解析器和配置驱动的模板,支持可配置文本以及启用/禁用行为,并提供默认值。
  • 将所有与 fortune 相关的硬编码 plain_result 和返回字符串(配置未加载、仅限群聊、缺少用户 ID、获取/刷新错误、刷新完成计数、启用/禁用、拉黑/取消拉黑/信任/取消信任消息)全部替换为使用新 fortune_* 消息键和占位符的 self._message 调用。
  • 新增 FortuneCommandHandler.message 帮助方法,使用 config.resolve_message(若可用),否则回退到带占位符插值的本地 defaults 字典。
  • 确保 LLM 工具处理器通过使用相同的消息键来镜像运行时命令行为,而不是内联格式化字符串。
  • 新增测试,验证配置的模板会被使用,并且在配置中禁用某个 fortune* 消息时,处理器会回退到内置默认值。
src/infrastructure/astrbot/commands/fortune.py
tests/infrastructure/test_fortune_messages.py
更新 ImageSender,使其在空 payload 和发送失败消息上依赖集中式消息解析器,并尊重 found/send-failed 提示的启用开关。
  • 在空 payload 时,调用 _resolve_message("empty_payload"),只有在返回非空消息时才发送提示,而不是无条件地发送硬编码字符串。
  • 将所有发送失败分支包装为调用 _send_failed_message(),仅当其返回非空字符串时才发出 plain_result,这样在禁用 send_failed 时可以完全抑制该消息。
  • 将 _send_failed_message 改为返回 Optional[str],并在可用时委托给 config.resolve_message("send_failed"),否则回退到之前的硬编码文本。
  • 在 ImageSender 上新增 _resolve_message(key, **kwargs),在可用时调用 config.resolve_message,否则返回 None。
  • 更新 _format_found_message,以检查 config.msg_found_enabled,并在 found 消息被禁用时返回 None。
  • 新增异步测试,验证禁用 found 消息时不会发送 found 消息,以及禁用 send_failed 时,在发送失败时不会发出失败消息。
src/infrastructure/sending/image_sender.py
tests/infrastructure/test_image_sender.py

技巧和命令

与 Sourcery 交互

  • 触发新的审查: 在 Pull Request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在审查评论下回复,要求 Sourcery 根据该评论创建 issue。你也可以在审查评论下回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai 以随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 总结: 在 Pull Request 正文任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 总结。你也可以在 Pull Request 中评论 @sourcery-ai summary 来在任意时间(重新)生成总结。
  • 生成审阅者指南: 在 Pull Request 中评论 @sourcery-ai guide,可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve 来解决所有 Sourcery 评论。如果你已经处理了所有评论且不想再看到它们,这会很有用。
  • 取消所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss 来取消所有现有的 Sourcery 审查。特别适合你希望从一次全新的审查开始的情况——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的控制面板 以:

  • 启用或禁用审查特性,例如 Sourcery 自动生成的 Pull Request 总结、审阅者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Makes Setu and Fortune user-facing prompts configuration-driven via a shared message model and runtime resolver, adds enable/toggle behavior and placeholder substitution, and updates Setu/Fortune command handlers and image sending behavior to consume those configurable messages with sensible fallbacks, plus tests and schema updates.

Sequence diagram for Setu message resolution and sending

sequenceDiagram
    actor User
    participant SetuCommand
    participant Config as ConfigObject
    participant Messages as MessagesConfig
    participant Event as AstrMessageEvent

    User->>SetuCommand: get_random_picture
    SetuCommand->>SetuCommand: _rate_limiter.acquire
    alt [rate limited]
        SetuCommand->>SetuCommand: _message rate_limited
        SetuCommand->>Config: get_config
        opt [config has resolve_message]
            SetuCommand->>Config: resolve_message rate_limited
            Config->>Messages: lookup messages.rate_limited
            Messages-->>Config: MessageTextConfig
            Config-->>SetuCommand: resolved text
        end
        SetuCommand->>Event: plain_result(text)
    else [not rate limited]
        SetuCommand->>SetuCommand: _fetch_and_send_images
        SetuCommand->>SetuCommand: _message fetching
        SetuCommand->>Config: get_config
        Config-->>SetuCommand: use resolve_message or defaults
        SetuCommand->>Event: plain_result(fetching message)
        Note over SetuCommand: image fetching and sending ...
    end
Loading

Flow diagram for resolve_message placeholder-aware lookup

flowchart TD
    A[resolve_message key, kwargs] --> B{key in
fetching/found/send_failed?}
    B -- Yes --> C{corresponding
msg_*_enabled?}
    C -- No --> Z[return None]
    C -- Yes --> D[load msg_*_text]
    B -- No --> E[getattr messages.key]
    E --> F{item exists and
enabled?}
    F -- No --> Z
    F -- Yes --> G[read item.text]
    D --> H[set result = text]
    G --> H
    H --> I{any kwargs?}
    I -- No --> J[return result]
    I -- Yes --> K[for each k,v in kwargs:
replace k with v]
    K --> J
Loading

File-Level Changes

Change Details Files
Introduce a generic, toggleable message config model and central message resolver on the plugin config, then wire all Setu/Fortune and sending flows to use it (with placeholder substitution).
  • Extend MessagesSendFailedConfig with an enabled flag and add a reusable MessageTextConfig model with enabled/text fields.
  • Expand MessagesConfig to include generic Setu and Fortune message keys (rate limiting, config not loaded, count validation, fetch errors, no/empty result, R18 docx failure, and many fortune-* status/error messages) with defaults using placeholders.
  • Add config.msg_send_failed_enabled property and a resolve_message(key, **kwargs) helper that returns None when the specific message or its enabled flag is absent/false, and performs naive str.replace placeholder substitution.
  • Update sample_config_dict test fixture so messages.send_failed now includes enabled=True by default.
src/shared/config/models.py
tests/shared/test_config_models.py
tests/conftest.py
Refactor Setu command handlers to use the shared message resolver for all user-facing text, including rate limiting, config errors, count validation, fetch errors, and no-result behavior, removing hardcoded notices from the Setu use case.
  • Replace hardcoded plain_result strings in get_random_picture, _handle_random_picture_internal, setu_command, _handle_setu_command_internal, and related exception paths with calls to self._message(key, **kwargs) using the new message keys and placeholders.
  • Emit the configurable "fetching" message (if enabled) before performing image fetches in _fetch_and_send_images.
  • When the Setu use case returns an empty payload, construct tags_info and resolve the configurable no_result message instead of using a hardcoded string.
  • Add a _message helper on the Setu command handler that first consults config.resolve_message and falls back to a local defaults dict with placeholder interpolation.
  • Change the LLM _llm_get_setu_handler to use config_not_loaded and fetch_failed keys instead of hardcoded strings.
  • Update GetSetuImagesUseCase.execute to return SetuImagesResult(payload=None) without embedding a notice, leaving presentation to the command layer.
  • Add a new test for the Setu use case to assert that empty results do not carry a hardcoded notice.
src/infrastructure/astrbot/commands/setu.py
src/application/setu/get_images.py
tests/application/test_setu_use_case.py
Refactor Fortune command handlers (including LLM tools) to use the shared message resolver and configuration-backed templates for all feedback and error messages, with configurable text and enable/disable behavior plus defaults.
  • Replace every hardcoded fortune-related plain_result and return string (config not loaded, group-only restriction, missing user id, get/refresh errors, refresh done counts, enable/disable, block/unblock/trust/untrust messages) with calls to self.message using the new fortune* message keys and placeholders.
  • Add a FortuneCommandHandler.message helper that uses config.resolve_message when available and falls back to a local defaults dict with placeholder interpolation.
  • Ensure LLM tool handlers mirror the runtime command behavior by using the same message keys instead of inline formatting.
  • Add tests verifying that configured templates are used and that disabling a fortune* message in config causes the handler to fall back to the built-in default.
src/infrastructure/astrbot/commands/fortune.py
tests/infrastructure/test_fortune_messages.py
Update ImageSender to rely on the central message resolver for empty-payload and send-failed messages, and to honor enabled toggles for found/send-failed prompts.
  • On empty payload, call _resolve_message("empty_payload") and only emit a notice if a non-empty message is returned, instead of unconditionally sending a hardcoded string.
  • Wrap all send-failed branches to call _send_failed_message() and only yield a plain_result if that returns a non-empty string, so disabling send_failed suppresses the message entirely.
  • Change _send_failed_message to return Optional[str] and delegate to config.resolve_message("send_failed") when available, otherwise defaulting to the prior hardcoded text.
  • Introduce _resolve_message(key, **kwargs) on ImageSender that consults config.resolve_message and returns None otherwise.
  • Update _format_found_message to check config.msg_found_enabled and return None when the found message is disabled.
  • Add async tests that validate found message disabling (no found message sent) and send_failed disabling (no failure message emitted when sending fails).
src/infrastructure/sending/image_sender.py
tests/infrastructure/test_image_sender.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并留下了一些高层次的反馈:

  • SetuCommandHandler._messageFortuneCommandHandler._message 中硬编码的回退消息字典,与 MessagesConfig/MessageTextConfig 中已经定义的默认值是重复的,这很容易导致文本内容随着时间产生偏差;建议将这些默认值统一集中到配置层里,让这些 helper 只调用 resolve_message,再加上一个最小化的通用回退逻辑即可。
  • 目前有一些消息同时存在通用版本和 fortune 专用版本(例如 config_not_loadedfortune_config_not_loaded,文本内容完全相同);在语义一致的情况下,建议合并或复用同一个 key,以缩小消息命名空间并简化配置。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The hardcoded fallback message dictionaries in `SetuCommandHandler._message` and `FortuneCommandHandler._message` duplicate the defaults already defined in `MessagesConfig`/`MessageTextConfig`, which makes it easy for texts to drift; consider centralizing these defaults in the config layer and having the helpers only call `resolve_message` plus a minimal generic fallback.
- You now have both generic and fortune-specific variants of some messages (e.g. `config_not_loaded` and `fortune_config_not_loaded` with the same text); consider consolidating or reusing a single key where the semantics are identical to keep the message namespace smaller and configuration simpler.

## Individual Comments

### Comment 1
<location path="tests/application/test_setu_use_case.py" line_range="11-20" />
<code_context>
+from astrbot_plugin_setu.src.application.setu.get_images import GetSetuImagesUseCase
+
+
+@pytest.mark.asyncio
+async def test_execute_returns_empty_payload_without_hardcoded_notice() -> None:
+    provider = MagicMock()
+    provider.fetch_and_download = AsyncMock(
+        return_value=ImagePayload(
+            urls=(),
+            raw_bytes=(),
+            file_paths=(),
+            items=(),
+            r18=False,
+            tags=(),
+        )
+    )
+
+    use_case = GetSetuImagesUseCase(provider)
+    result = await use_case.execute(1, ["少女"], False)
+
+    assert result.payload is None
+    assert result.notice is None
</code_context>
<issue_to_address>
**suggestion (testing):** Complement the empty-payload test with a non-empty payload case for `GetSetuImagesUseCase`

To also cover the non-empty branch, please add a test where `fetch_and_download` returns a non-empty `ImagePayload`, and assert that `result.payload` reflects that payload (or is at least non-empty) and `result.notice` remains `None`. This will exercise both `payload.is_empty` and non-empty paths and protect the DTO semantics from regressions.
</issue_to_address>

Sourcery 对开源项目免费使用——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The hardcoded fallback message dictionaries in SetuCommandHandler._message and FortuneCommandHandler._message duplicate the defaults already defined in MessagesConfig/MessageTextConfig, which makes it easy for texts to drift; consider centralizing these defaults in the config layer and having the helpers only call resolve_message plus a minimal generic fallback.
  • You now have both generic and fortune-specific variants of some messages (e.g. config_not_loaded and fortune_config_not_loaded with the same text); consider consolidating or reusing a single key where the semantics are identical to keep the message namespace smaller and configuration simpler.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The hardcoded fallback message dictionaries in `SetuCommandHandler._message` and `FortuneCommandHandler._message` duplicate the defaults already defined in `MessagesConfig`/`MessageTextConfig`, which makes it easy for texts to drift; consider centralizing these defaults in the config layer and having the helpers only call `resolve_message` plus a minimal generic fallback.
- You now have both generic and fortune-specific variants of some messages (e.g. `config_not_loaded` and `fortune_config_not_loaded` with the same text); consider consolidating or reusing a single key where the semantics are identical to keep the message namespace smaller and configuration simpler.

## Individual Comments

### Comment 1
<location path="tests/application/test_setu_use_case.py" line_range="11-20" />
<code_context>
+from astrbot_plugin_setu.src.application.setu.get_images import GetSetuImagesUseCase
+
+
+@pytest.mark.asyncio
+async def test_execute_returns_empty_payload_without_hardcoded_notice() -> None:
+    provider = MagicMock()
+    provider.fetch_and_download = AsyncMock(
+        return_value=ImagePayload(
+            urls=(),
+            raw_bytes=(),
+            file_paths=(),
+            items=(),
+            r18=False,
+            tags=(),
+        )
+    )
+
+    use_case = GetSetuImagesUseCase(provider)
+    result = await use_case.execute(1, ["少女"], False)
+
+    assert result.payload is None
+    assert result.notice is None
</code_context>
<issue_to_address>
**suggestion (testing):** Complement the empty-payload test with a non-empty payload case for `GetSetuImagesUseCase`

To also cover the non-empty branch, please add a test where `fetch_and_download` returns a non-empty `ImagePayload`, and assert that `result.payload` reflects that payload (or is at least non-empty) and `result.notice` remains `None`. This will exercise both `payload.is_empty` and non-empty paths and protect the DTO semantics from regressions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +11 to +20
@pytest.mark.asyncio
async def test_execute_returns_empty_payload_without_hardcoded_notice() -> None:
provider = MagicMock()
provider.fetch_and_download = AsyncMock(
return_value=ImagePayload(
urls=(),
raw_bytes=(),
file_paths=(),
items=(),
r18=False,
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.

suggestion (testing):GetSetuImagesUseCase 在空负载用例的基础上补充一个非空负载的测试用例

为了同时覆盖非空分支,请新增一个测试:让 fetch_and_download 返回一个非空的 ImagePayload,并断言 result.payload 能够反映该负载(或至少为非空),且 result.notice 仍然为 None。这样可以同时覆盖 payload.is_empty 和非空路径,并防止 DTO 语义在未来发生回归。

Original comment in English

suggestion (testing): Complement the empty-payload test with a non-empty payload case for GetSetuImagesUseCase

To also cover the non-empty branch, please add a test where fetch_and_download returns a non-empty ImagePayload, and assert that result.payload reflects that payload (or is at least non-empty) and result.notice remains None. This will exercise both payload.is_empty and non-empty paths and protect the DTO semantics from regressions.

@FlanChanXwO FlanChanXwO merged commit 59f24bc into master May 18, 2026
1 of 2 checks passed
@FlanChanXwO FlanChanXwO deleted the fix-configurable-messages-setu-fortune branch May 18, 2026 05:06
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.

1 participant