-
Notifications
You must be signed in to change notification settings - Fork 2
fix: avoid duplicate sends on NapCat timeout #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): 考虑增加一个“负向测试”,验证非 OneBot 类的平台不会把相同的异常视为待投递
当前测试已经通过
mock_event.platform.name = "aiocqhttp"覆盖了 OneBot 类平台的路径,请再补充一个使用非 OneBot 类平台名(例如你现有适配器栈里的另一个平台)的测试,其中同样的ActionTimeout会导致正常失败,而不是被标记为pending_delivery。这样可以验证基于平台的分类逻辑,并防止未来的回归不小心把 OneBot/NapCat 的行为扩展到更广的平台范围。建议的实现方式:
ImageSender、send_image以及pending_delivery属性(或同等标记)的名字与该测试模块内实际使用的保持一致;如果你的代码使用了不同的发送类、方法或标记字段来表示“待投递”,请相应调整。pending_delivery字段,或使用专门的状态枚举),请在这里镜像同样的结构,并断言平台"telegram"会产生正常失败,而不是该待投递状态。"telegram"替换为你当前适配器栈中已经存在的其他非 OneBot 适配器名称(例如"kook"、"discord"等),以保持测试与实际支持的平台一致。ActionTimeout),那就需要调整with pytest.raises(ActionTimeout)这段代码,使之匹配你的图片发送器实际暴露失败的方式,并断言它不会被标记为待投递。Original comment in English
suggestion (testing): Consider a negative test showing non-OneBot-like platforms do not treat similar exceptions as pending delivery
Since this test covers the OneBot-like path via
mock_event.platform.name = "aiocqhttp", please also add a complementary test using a non-OneBot-like platform name (e.g., another adapter in your stack) where the sameActionTimeoutresults in a normal failure rather thanpending_delivery. This will verify the platform-based classification and help prevent regressions that accidentally extend the OneBot/NapCat behavior more broadly.Suggested implementation:
ImageSender,send_image, and thepending_deliveryattribute (or equivalent) match what is actually used in this test module; adjust them if your code uses a different sender class, method, or flag to indicate pending delivery.pending_deliveryfield or a dedicated status enum), mirror that structure here and assert that the platform"telegram"produces a normal failure instead of that pending-delivery classification."telegram"with another non-OneBot adapter name already present in your stack (e.g."kook","discord", etc.) to keep the test aligned with the actual platforms supported by your infrastructure.ActionTimeout), adapt thewith pytest.raises(ActionTimeout)block to match the way your image sender exposes failures and then assert that it is not marked as pending delivery.