@@ -25,7 +25,7 @@ async def test_render_error_bot(app: App):
2525 {
2626 "loc" : ("homepage" ,),
2727 "msg" : "项目主页不可访问。" ,
28- "type" : "value_error.homepage.unreachable " ,
28+ "type" : "value_error.homepage" ,
2929 "ctx" : {"status_code" : 404 },
3030 "input" : "https://www.baidu.com" ,
3131 },
@@ -92,7 +92,7 @@ async def test_render_error_adapter(app: App):
9292 {
9393 "loc" : ("homepage" ,),
9494 "msg" : "项目主页不可访问。" ,
95- "type" : "value_error.homepage.unreachable " ,
95+ "type" : "value_error.homepage" ,
9696 "ctx" : {"status_code" : 404 },
9797 "input" : "https://www.baidu.com" ,
9898 },
@@ -158,7 +158,7 @@ async def test_render_error_plugin(app: App, mocker: MockFixture):
158158 {
159159 "loc" : ("homepage" ,),
160160 "msg" : "项目主页不可访问。" ,
161- "type" : "value_error.homepage.unreachable " ,
161+ "type" : "value_error.homepage" ,
162162 "ctx" : {"status_code" : 404 },
163163 "input" : "https://www.baidu.com" ,
164164 },
@@ -400,3 +400,50 @@ async def test_render_unknown_error(app: App, mocker: MockFixture):
400400 comment
401401 == """# 📃 商店发布检查结果\n \n > Plugin: 帮助\n \n **⚠️ 在发布检查过程中,我们发现以下问题:**\n \n <pre><code><li>⚠️ tests > 2 > test: unknown error</li></code></pre>\n \n <details>\n <summary>详情</summary>\n <pre><code><li>✅ 插件 <a href="https://github.com/owner/repo/actions/runs/123456">加载测试</a> 通过。</li></code></pre>\n </details>\n \n ---\n \n 💡 如需修改信息,请直接修改 issue,机器人会自动更新检查结果。\n 💡 当插件加载测试失败时,请发布新版本后在当前页面下评论任意内容以触发测试。\n \n \n 💪 Powered by [NoneFlow](https://github.com/nonebot/noneflow)\n <!-- NONEFLOW -->\n """
402402 )
403+
404+
405+ async def test_render_http_error (app : App , mocker : MockFixture ):
406+ """网络请求报错"""
407+ from src .plugins .publish .config import plugin_config
408+ from src .plugins .publish .render import render_comment
409+ from src .utils .validation import PublishType , ValidationDict
410+
411+ mocker .patch .object (plugin_config , "plugin_test_result" , True )
412+ mocker .patch .object (plugin_config , "plugin_test_metadata" , {})
413+
414+ result : ValidationDict = {
415+ "valid" : False ,
416+ "data" : {
417+ "author" : "he0119" ,
418+ "tags" : [],
419+ "is_official" : False ,
420+ },
421+ "errors" : [
422+ {
423+ "loc" : ("homepage" ,),
424+ "msg" : "项目主页不可访问。" ,
425+ "type" : "value_error.homepage" ,
426+ "ctx" : {"status_code" : 404 },
427+ "input" : "https://www.baidu.com" ,
428+ },
429+ {
430+ "loc" : ("homepage" ,),
431+ "msg" : "项目主页无法访问。" ,
432+ "type" : "value_error.homepage" ,
433+ "ctx" : {
434+ "status_code" : - 1 ,
435+ "msg" : "Request URL is missing an 'http://' or 'https://' protocol." ,
436+ },
437+ "input" : "12312" ,
438+ },
439+ ],
440+ "type" : PublishType .PLUGIN ,
441+ "name" : "帮助" ,
442+ "author" : "he0119" ,
443+ }
444+
445+ comment = await render_comment (result )
446+ assert (
447+ comment
448+ == """# 📃 商店发布检查结果\n \n > Plugin: 帮助\n \n **⚠️ 在发布检查过程中,我们发现以下问题:**\n \n <pre><code><li>⚠️ 项目 <a href="https://www.baidu.com">主页</a> 返回状态码 404。<dt>请确保你的项目主页可访问。</dt></li><li>⚠️ 项目 <a href="12312">主页</a> 访问出错。<details><summary>错误信息</summary>Request URL is missing an 'http://' or 'https://' protocol.</details></li></code></pre>\n \n <details>\n <summary>详情</summary>\n <pre><code><li>✅ 插件 <a href="https://github.com/owner/repo/actions/runs/123456">加载测试</a> 通过。</li></code></pre>\n </details>\n \n ---\n \n 💡 如需修改信息,请直接修改 issue,机器人会自动更新检查结果。\n 💡 当插件加载测试失败时,请发布新版本后在当前页面下评论任意内容以触发测试。\n \n \n 💪 Powered by [NoneFlow](https://github.com/nonebot/noneflow)\n <!-- NONEFLOW -->\n """
449+ )
0 commit comments