✨ 跟项目能跑起来就差这一步!这次狠狠修了一波: 🩺 修复40+损坏Python文件 - 补全所有缺少的class定义头(plugin-loader-pro、code-reviewer、 http-api/ws-api/http-tcp、webui/dashboard/log-terminal 等) - 修复中文括号、字符串未闭合、缩进错乱等语法问题 🔗 创建符号链接 plugin_bridge -> plugin-bridge - 解决Python模块路径不支持连字符的问题 - 关联修复 plugin-bridge 中错误的 import 路径 🧹 清理废弃代码 - 删除 oss/tui/ 目录(已废弃) - 清理所有 __pycache__ 和 .pyc 缓存文件 ✅ 全量语法检查通过,零错误! 📋 ai.md 新增代码审计报告和分阶段修复计划 🗺️ 所有插件 use() 调用现在走统一路径
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
"""Tests for Node.js Adapter Plugin"""
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
import tempfile
|
|
import shutil
|
|
import pytest
|
|
|
|
PLUGIN_DIR = os.path.join(os.path.dirname(__file__), '..', 'store', 'NebulaShell', 'nodejs-adapter')
|
|
sys.path.insert(0, PLUGIN_DIR)
|
|
|
|
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
|
|
|
|
|
|
@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)
|
|
|
|
|
|
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_get_capabilities(self, adapter):
|
|
versions = adapter.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_stop_hook(self):
|
|
init = main_module.init
|
|
get_info = main_module.get_info
|
|
context = {}
|
|
init(context)
|
|
info = get_info(context)
|
|
assert isinstance(info, dict)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
pytest.main([__file__, '-v'])
|