重大重构:引擎模块拆分 + P0插件实现 + 55个Bug修复
核心变更: - engine.py(1781行)拆分为8个独立模块: lifecycle/security/deps/ datastore/pl_injector/watcher/signature/manager - 新增plugin-bridge: 事件总线 + 服务注册 + RPC通信 - 新增i18n: 国际化/多语言翻译支持 - 新增plugin-storage: 插件键值/文件存储 - 新增ws-api: WebSocket实时通信(pub/sub + 自定义处理器) - nodejs-adapter统一为Plugin ABC模式 Bug修复: - 修复load_all()中store_dir未定义崩溃 - 修复DependencyResolver入度计算(拓扑排序) - 修复PermissionError隐藏内置异常 - 修复CORS中间件头部未附加到响应 - 修复IntegrityChecker跳过__pycache__目录 - 修复版本号不一致(v2.0.0→v1.2.0) - 修复测试文件的Logger导入/路径/私有方法调用 - 修复context.py缺少typing导入 - 修复config.py STORE_DIR默认路径(./mods→./store) 测试覆盖: 14→91个测试, 全部通过
This commit is contained in:
@@ -14,46 +14,32 @@ import importlib.util
|
||||
spec = importlib.util.spec_from_file_location("nodejs_adapter_main", os.path.join(PLUGIN_DIR, "main.py"))
|
||||
main_module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(main_module)
|
||||
NodeJSAdapter = main_module.NodeJSAdapter
|
||||
NodeJSAdapterPlugin = main_module.NodeJSAdapterPlugin
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def adapter():
|
||||
return NodeJSAdapter()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_plugin_dir():
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
pkg_dir = os.path.join(temp_dir, 'pkg')
|
||||
os.makedirs(pkg_dir)
|
||||
yield temp_dir
|
||||
shutil.rmtree(temp_dir)
|
||||
def plugin():
|
||||
return NodeJSAdapterPlugin()
|
||||
|
||||
|
||||
class TestNodeJSAdapter:
|
||||
def test_adapter_name(self, adapter):
|
||||
assert adapter.name == "nodejs-adapter"
|
||||
assert adapter.version == "1.0.0"
|
||||
assert "Node.js" in adapter.description
|
||||
def test_plugin_name(self, plugin):
|
||||
assert plugin.name == "nodejs-adapter"
|
||||
assert plugin.version == "1.0.0"
|
||||
|
||||
def test_get_capabilities(self, adapter):
|
||||
versions = adapter.check_versions()
|
||||
def test_check_versions(self, plugin):
|
||||
versions = plugin.check_versions()
|
||||
assert isinstance(versions, dict)
|
||||
|
||||
def test_init_hook(self):
|
||||
start = main_module.start
|
||||
context = {}
|
||||
result = start(context)
|
||||
assert result['status'] == 'inactive'
|
||||
def test_lifecycle(self, plugin):
|
||||
plugin.init()
|
||||
plugin.start()
|
||||
plugin.stop()
|
||||
# no exception = pass
|
||||
|
||||
def test_stop_hook(self):
|
||||
init = main_module.init
|
||||
get_info = main_module.get_info
|
||||
context = {}
|
||||
init(context)
|
||||
info = get_info(context)
|
||||
assert isinstance(info, dict)
|
||||
def test_get_adapter(self, plugin):
|
||||
adapter = plugin.get_adapter()
|
||||
assert adapter is not None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user