Skip to content

Commit

Permalink
test: 修复其他测试
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Jan 6, 2025
1 parent 02609a5 commit dc165e6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
8 changes: 6 additions & 2 deletions tests/plugins/github/publish/render/test_publish_render.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from inline_snapshot import snapshot
from nonebug import App

from tests.providers.validation.utils import generate_bot_data


async def test_render_empty(app: App):
"""测试没有数据和错误时的输出"""
from src.plugins.github.plugins.publish.render import render_comment
from src.providers.validation import PublishType, ValidationDict
from src.providers.validation import BotPublishInfo, PublishType, ValidationDict

result = ValidationDict(
type=PublishType.BOT,
raw_data={"name": "name"},
info=BotPublishInfo.model_construct(**generate_bot_data()),
)

comment = await render_comment(result)
Expand Down Expand Up @@ -38,11 +41,12 @@ async def test_render_empty(app: App):
async def test_render_reuse(app: App):
"""复用评论"""
from src.plugins.github.plugins.publish.render import render_comment
from src.providers.validation import PublishType, ValidationDict
from src.providers.validation import BotPublishInfo, PublishType, ValidationDict

result = ValidationDict(
type=PublishType.BOT,
raw_data={"name": "name"},
info=BotPublishInfo.model_construct(**generate_bot_data()),
)

comment = await render_comment(result, True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from nonebug import App
from pytest_mock import MockFixture

from tests.providers.validation.utils import generate_plugin_data


async def test_render_data_bot(app: App):
"""机器人验证数据"""
Expand Down Expand Up @@ -211,7 +213,7 @@ async def test_render_data_plugin(app: App, mocker: MockFixture):
async def test_render_data_plugin_supported_adapters(app: App, mocker: MockFixture):
"""插件支持的适配器"""
from src.plugins.github.plugins.publish.render import render_comment
from src.providers.validation import PublishType, ValidationDict
from src.providers.validation import PluginPublishInfo, PublishType, ValidationDict

result = ValidationDict(
type=PublishType.PLUGIN,
Expand All @@ -228,7 +230,7 @@ async def test_render_data_plugin_supported_adapters(app: App, mocker: MockFixtu
"load": True,
"skip_test": False,
},
info=None,
info=PluginPublishInfo.model_construct(**generate_plugin_data()),
errors=[],
)

Expand Down
47 changes: 42 additions & 5 deletions tests/providers/store_test/test_validate_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,45 @@ async def test_validate_plugin_skip_test_plugin_test_failed(
StoreTestResult(
config="",
outputs={
"validation": None,
"validation": {
"data": {
"module_name": "nonebot_plugin_treehelp",
"project_link": "nonebot-plugin-treehelp",
"time": "2024-07-13T04:41:40.905441Z",
"version": "0.3.9",
"name": "帮助",
"desc": "获取插件帮助信息",
"author": "he0119",
"author_id": 1,
"homepage": "https://nonebot.dev/",
"tags": [],
"is_official": False,
"type": "application",
"supported_adapters": None,
"load": True,
"skip_test": True,
"test_output": """\
创建测试目录 plugin_test
For further information visit https://errors.pydantic.dev/2.9/v/model_type\x1b[0m\
""",
},
"errors": [
{
"type": "plugin.metadata",
"loc": ("metadata",),
"msg": "无法获取到插件元数据",
"input": False,
"ctx": {"load": None},
}
],
},
"load": """\
创建测试目录 plugin_test
For further information visit https://errors.pydantic.dev/2.9/v/model_type\x1b[0m\
""",
"metadata": None,
},
results={"validation": True, "load": False, "metadata": False},
results={"validation": False, "load": False, "metadata": False},
test_env={"python==3.12.7": True},
version="0.3.9",
)
Expand All @@ -350,7 +381,7 @@ async def test_validate_plugin_skip_test_plugin_test_failed(
tags=[],
time="2024-07-13T04:41:40.905441Z",
type="application",
valid=True,
valid=False,
version="0.3.9",
)
)
Expand Down Expand Up @@ -424,7 +455,6 @@ async def test_validate_plugin_failed_with_previous(
"is_official": True,
"type": "application",
"supported_adapters": None,
"metadata": False,
"skip_test": False,
"version": "0.3.9",
"test_output": """\
Expand All @@ -444,7 +474,14 @@ async def test_validate_plugin_failed_with_previous(
For further information visit https://errors.pydantic.dev/2.9/v/model_type\x1b[0m\
"""
},
}
},
{
"type": "plugin.metadata",
"loc": ("metadata",),
"msg": "无法获取到插件元数据",
"input": False,
"ctx": {"load": None},
},
],
},
"load": """\
Expand Down
8 changes: 7 additions & 1 deletion tests/providers/validation/fields/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async def test_fields_missing_plugin(mocked_api: MockRouter) -> None:
"author_id": 1,
"tags": [{"label": "test", "color": "#ffffff"}],
"supported_adapters": None,
"metadata": False,
"skip_test": False,
"test_output": "error",
}
Expand Down Expand Up @@ -138,6 +137,13 @@ async def test_fields_missing_plugin(mocked_api: MockRouter) -> None:
"input": False,
"ctx": {"output": "error"},
},
{
"type": "plugin.metadata",
"loc": ("metadata",),
"msg": "无法获取到插件元数据",
"input": False,
"ctx": {"load": None},
},
]
)

Expand Down

0 comments on commit dc165e6

Please sign in to comment.