MCPcopy Create free account
hub / github.com/AstrBotDevs/AstrBot / _write_local_test_plugin

Function _write_local_test_plugin

tests/test_plugin_manager.py:31–48  ·  view source on GitHub ↗

Creates a minimal valid plugin structure.

(plugin_path: Path, repo_url: str, version: str = "1.0.0")

Source from the content-addressed store, hash-verified

29
30
31def _write_local_test_plugin(plugin_path: Path, repo_url: str, version: str = "1.0.0"):
32 """Creates a minimal valid plugin structure."""
33 plugin_path.mkdir(parents=True, exist_ok=True)
34 metadata = {
35 "name": TEST_PLUGIN_NAME,
36 "repo": repo_url,
37 "version": version,
38 "author": "AstrBot Team",
39 "desc": "Local test plugin",
40 "short_desc": "Local test short description",
41 }
42 with open(plugin_path / "metadata.yaml", "w", encoding="utf-8") as f:
43 yaml.dump(metadata, f)
44 with open(plugin_path / "main.py", "w", encoding="utf-8") as f:
45 f.write("from astrbot.api.star import Star, Context, StarManager\n")
46 f.write("@StarManager.register\n")
47 f.write("class HelloWorld(Star):\n")
48 f.write(" def __init__(self, context: Context): ...\n")
49
50
51def _write_requirements(plugin_path: Path):

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected