73 lines
2.4 KiB
Python
Executable File
73 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Expression Skill 测试 (简化版,无需外部依赖)"""
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
import sys
|
|
import os
|
|
|
|
# 添加父目录到路径
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
# 模拟必要的模块
|
|
class MockModule:
|
|
def __getattr__(self, name):
|
|
raise ImportError(f"Module '{name}' not available (for testing)")
|
|
|
|
sys.modules['matplotlib'] = MockModule()
|
|
sys.modules['seaborn'] = MockModule()
|
|
sys.modules['sklearn'] = MockModule()
|
|
|
|
# 加载配置测试
|
|
class TestExpressionConfig(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
# 只测试配置加载,不导入实际类
|
|
import yaml
|
|
config_path = Path(__file__).parent.parent / "config.yaml"
|
|
with open(config_path) as f:
|
|
self.config = yaml.safe_load(f)
|
|
self.temp_dir = Path(tempfile.mkdtemp())
|
|
|
|
def test_config_structure(self):
|
|
"""测试配置结构"""
|
|
self.assertIn("skill", self.config)
|
|
self.assertIn("parameters", self.config)
|
|
self.assertEqual(self.config["skill"]["name"], "expression")
|
|
|
|
def test_config_source(self):
|
|
"""测试数据源"""
|
|
self.assertEqual(self.config["skill"]["source"], "bbav2/rnaseq/de_analysis.py")
|
|
|
|
def test_parameters(self):
|
|
"""测试参数配置"""
|
|
self.assertIn("statistics", self.config["parameters"])
|
|
self.assertIn("visualization", self.config["parameters"])
|
|
|
|
def test_demo_output_structure(self):
|
|
"""测试Demo输出结构"""
|
|
# 创建输出目录
|
|
demo_dir = self.temp_dir / "demo_data"
|
|
demo_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
# 模拟输出文件
|
|
(self.temp_dir / "report.md").write_text("# Test Report")
|
|
(self.temp_dir / "commands.sh").write_text("#!/bin/bash")
|
|
(self.temp_dir / "environment.yml").write_text("name: test")
|
|
(self.temp_dir / "checksums.sha256").write_text("")
|
|
(self.temp_dir / "DE_results.txt").write_text("gene\tlog2FC\tpvalue")
|
|
|
|
# 检查文件存在
|
|
self.assertTrue((self.temp_dir / "report.md").exists())
|
|
self.assertTrue((self.temp_dir / "commands.sh").exists())
|
|
self.assertTrue((self.temp_dir / "environment.yml").exists())
|
|
|
|
def tearDown(self):
|
|
import shutil
|
|
shutil.rmtree(self.temp_dir, ignore_errors=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# 只运行配置测试
|
|
unittest.main(exit=False) |