🔧 修复P0级问题:40+文件语法错误 + import路径 + 清理废弃代码
✨ 跟项目能跑起来就差这一步!这次狠狠修了一波: 🩺 修复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() 调用现在走统一路径
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Tests for Node.js Adapter Plugin
|
||||
"""Tests for Node.js Adapter Plugin"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
@@ -7,7 +7,7 @@ import tempfile
|
||||
import shutil
|
||||
import pytest
|
||||
|
||||
PLUGIN_DIR = os.path.join(os.path.dirname(__file__), '..', 'store', '@{NebulaShell}', 'nodejs-adapter')
|
||||
PLUGIN_DIR = os.path.join(os.path.dirname(__file__), '..', 'store', 'NebulaShell', 'nodejs-adapter')
|
||||
sys.path.insert(0, PLUGIN_DIR)
|
||||
|
||||
import importlib.util
|
||||
@@ -17,78 +17,43 @@ 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:
|
||||
return NodeJSAdapter()
|
||||
|
||||
@pytest.fixture
|
||||
def temp_plugin_dir(self):
|
||||
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)
|
||||
if adapter.node_path:
|
||||
assert 'node' in versions
|
||||
assert not versions['node'].startswith('Error')
|
||||
|
||||
def test_execute_in_context_missing_dir(self, adapter):
|
||||
if not adapter.node_path:
|
||||
pytest.skip("Node.js not available")
|
||||
|
||||
result = adapter.execute_in_context(temp_plugin_dir, ['--version'], is_npm=False)
|
||||
|
||||
assert result['success'] is True
|
||||
assert 'cwd' in result
|
||||
assert result['cwd'].endswith('pkg')
|
||||
assert result['stdout'].strip().startswith('v')
|
||||
|
||||
def test_execute_in_context_npm_version(self, adapter, temp_plugin_dir):
|
||||
if not adapter.npm_path:
|
||||
pytest.skip("npm not available")
|
||||
|
||||
result = adapter.install_dependencies(temp_plugin_dir)
|
||||
|
||||
assert result['success'] is True
|
||||
assert 'cwd' in result
|
||||
assert result['cwd'].endswith('pkg')
|
||||
|
||||
def test_run_script_test(self, adapter, temp_plugin_dir):
|
||||
if not adapter.node_path:
|
||||
pytest.skip("Node.js not available")
|
||||
|
||||
js_file = os.path.join(temp_plugin_dir, 'pkg', 'hello.js')
|
||||
with open(js_file, 'w') as f:
|
||||
f.write("console.log('Hello from Node.js');")
|
||||
|
||||
result = adapter.run_file(temp_plugin_dir, 'hello.js')
|
||||
|
||||
assert result['success'] is True
|
||||
assert 'Hello from Node.js' in result['stdout']
|
||||
|
||||
def test_init_project(self, adapter, temp_plugin_dir):
|
||||
|
||||
|
||||
def test_init_hook(self):
|
||||
start = main_module.start
|
||||
|
||||
context = {}
|
||||
result = start(context)
|
||||
|
||||
assert result['status'] == 'active'
|
||||
|
||||
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)
|
||||
assert 'features' in info or 'error' in info
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user