32 行
1.1 KiB
Python
32 行
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from core.identity import RequestContext
|
|
from main import PLUGIN_NAME, dispatch_web_request, get_plugin_manifest
|
|
|
|
|
|
class PluginEntrypointTests(unittest.TestCase):
|
|
def test_plugin_manifest_exposes_astrbot_mounts(self):
|
|
manifest = get_plugin_manifest()
|
|
|
|
self.assertEqual(manifest["plugin_name"], PLUGIN_NAME)
|
|
self.assertTrue(manifest["api_base"].endswith("astrbot_plugin_imagestudio"))
|
|
self.assertIn("web", manifest)
|
|
self.assertTrue(any(route["endpoint"] == "dashboard/summary" for route in manifest["routes"]))
|
|
|
|
def test_dispatch_web_request_delegates_to_adapter(self):
|
|
ctx = RequestContext.from_astrbot(username="admin", user_id="user_001")
|
|
|
|
response = dispatch_web_request(
|
|
ctx,
|
|
"GET",
|
|
"/api/v1/plugins/extensions/astrbot_plugin_imagestudio/ui/bootstrap",
|
|
)
|
|
|
|
self.assertTrue(response["ok"])
|
|
self.assertEqual(response["data"]["plugin_name"], PLUGIN_NAME)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|