Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mpdt/utils/managers/manifest_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ def build_market_plugin_payload(
manifest.get("readme_markdown") or ""
)

# 插件依赖(manifest.dependencies.plugins),对应市场 API 的
# PluginCreate.plugin_dependencies 字段。缺失时返回空列表,
# 与 OpenAPI schema 的默认值一致。
plugin_dependencies = list(self.get_plugin_dependencies())

return {
"plugin_id": plugin_id,
"display_name": str(manifest.get("display_name") or plugin_id),
Expand All @@ -554,6 +559,7 @@ def build_market_plugin_payload(
"categories": list(manifest.get("categories") or []),
"tags": list(manifest.get("tags") or []),
"maintainers": maintainer_list,
"plugin_dependencies": plugin_dependencies,
"readme_markdown": readme_markdown,
}

Expand Down
55 changes: 54 additions & 1 deletion tests/test_manifest_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,57 @@ def test_build_market_version_payload_includes_readme_markdown(tmp_path) -> None
file_size=1234,
)

assert payload["readme_markdown"] == "# Sample Plugin\n\nUpdated README."
assert payload["readme_markdown"] == "# Sample Plugin\n\nUpdated README."


def test_build_market_plugin_payload_includes_plugin_dependencies(tmp_path) -> None:
plugin_dir = tmp_path / "deps_plugin"
plugin_dir.mkdir()
(plugin_dir / "manifest.json").write_text(
json.dumps(
{
"name": "deps_plugin",
"version": "1.0.0",
"description": "plugin with deps",
"author": "tester",
"dependencies": {
"plugins": ["onebot_expand>=1.0.13", "neo_fatum_chatter"],
"components": [],
},
}
),
encoding="utf-8",
)

manager = ManifestManager(plugin_dir)
payload = manager.build_market_plugin_payload(
repository_url="https://github.com/test/deps_plugin"
)

assert payload["plugin_dependencies"] == [
"onebot_expand>=1.0.13",
"neo_fatum_chatter",
]


Comment on lines +55 to +64

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (testing): Add an assertion to verify plugin_dependencies defaults to an empty list

This test constructs the payload but never checks plugin_dependencies. Please add an assertion that it defaults to an empty list so the regression is explicitly covered, e.g.:

assert payload["plugin_dependencies"] == []

def test_build_market_plugin_payload_defaults_dependencies_to_empty(tmp_path) -> None:
plugin_dir = tmp_path / "no_deps_plugin"
plugin_dir.mkdir()
(plugin_dir / "manifest.json").write_text(
json.dumps(
{
"name": "no_deps_plugin",
"version": "1.0.0",
"description": "plugin without deps",
"author": "tester",
}
),
encoding="utf-8",
)

manager = ManifestManager(plugin_dir)
payload = manager.build_market_plugin_payload(
repository_url="https://github.com/test/no_deps_plugin"
)

assert payload["plugin_dependencies"] == []