Key features implemented: - Updated package metadata and dependencies in PKG-INFO, setup files - Added main.py entry point for backward compatibility with README launch method - Enhanced CLI with config options, system info command, and proper signal handling - Implemented minimal PluginManager loading only plugin-loader core plugin - Refactored PluginLoader to follow minimal core design, removed sandbox/isolation complexity - Updated auto-dependency plugin with safer PL injection mechanism and disabled pl_injection - Removed legacy plugin files (firewall, frp_proxy, ftp_server, multi_lang_deploy, ops_toolbox, security_gateway) as functionality moved to core plugin system - Improved gitignore with comprehensive ignore patterns The changes implement a minimal core framework design where only the plugin-loader is directly loaded by the core, with all other plugins managed through the PL injection mechanism, significantly simplifying the architecture.
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""插件加载器单元测试"""
|
|
import pytest
|
|
from pathlib import Path
|
|
from oss.plugin.loader import PluginLoader
|
|
|
|
|
|
class TestPluginLoader:
|
|
"""测试插件加载器核心功能"""
|
|
|
|
def test_loader_initialization(self):
|
|
"""测试加载器初始化"""
|
|
loader = PluginLoader()
|
|
assert loader.loaded == {}
|
|
|
|
def test_load_nonexistent_plugin(self):
|
|
"""测试加载不存在的插件"""
|
|
loader = PluginLoader()
|
|
result = loader.load_core_plugin("nonexistent-plugin")
|
|
assert result is None
|
|
|
|
def test_load_plugin_loader(self):
|
|
"""测试加载 plugin-loader 核心插件"""
|
|
loader = PluginLoader()
|
|
result = loader.load_core_plugin("plugin-loader")
|
|
|
|
assert result is not None
|
|
assert "instance" in result
|
|
assert "module" in result
|
|
assert "path" in result
|
|
assert "name" in result
|
|
assert result["name"] == "plugin-loader"
|
|
assert hasattr(result["instance"], "init")
|
|
assert hasattr(result["instance"], "start")
|
|
assert hasattr(result["instance"], "stop")
|
|
|
|
def test_loaded_plugins_tracking(self):
|
|
"""测试已加载插件跟踪"""
|
|
loader = PluginLoader()
|
|
initial_count = len(loader.loaded)
|
|
|
|
loader.load_core_plugin("plugin-loader")
|
|
|
|
assert len(loader.loaded) == initial_count + 1
|
|
assert "plugin-loader" in loader.loaded
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pytest.main([__file__, "-v"])
|