38 行
1.4 KiB
Python
38 行
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from core.runtime_compat import probe_runtime_capabilities
|
|
|
|
|
|
class RuntimeCompatTests(unittest.TestCase):
|
|
def test_probe_is_safe_without_astrbot_runtime(self) -> None:
|
|
result = probe_runtime_capabilities(
|
|
context=type("Context", (), {})(),
|
|
plugin_name="astrbot_plugin_memory_companion_ops",
|
|
plugin_version="1.6.2-ops.1",
|
|
)
|
|
payload = result.to_dict()
|
|
self.assertEqual("astrbot_plugin_memory_companion_ops", payload["plugin_name"])
|
|
self.assertIn(payload["compatibility_level"], {"unsupported", "degraded", "full"})
|
|
self.assertIsInstance(payload["capabilities"], dict)
|
|
self.assertIsInstance(payload["warnings"], list)
|
|
|
|
def test_event_capabilities_are_detected_without_calling_event(self) -> None:
|
|
event = type(
|
|
"Event",
|
|
(),
|
|
{
|
|
"unified_msg_origin": "qq:private:1",
|
|
"send": lambda self, *args, **kwargs: None,
|
|
"stop_event": lambda self: None,
|
|
},
|
|
)()
|
|
result = probe_runtime_capabilities(event=event)
|
|
self.assertTrue(result.capabilities["event_unified_msg_origin"])
|
|
self.assertTrue(result.capabilities["event_send"])
|
|
self.assertTrue(result.capabilities["event_stop"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|