Repository navigation
Expand file tree
/
Copy pathconftest.py
More file actions
66 lines (52 loc) · 1.64 KB
/
Copy pathconftest.py
File metadata and controls
66 lines (52 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
"""
Super Dev 测试配置
"""
import pytest
import tempfile
import shutil
from pathlib import Path
from typing import Generator
from super_dev.config import ConfigManager, ProjectConfig
from super_dev.orchestrator import WorkflowEngine, WorkflowContext
@pytest.fixture(autouse=True)
def reset_global_config_manager():
"""重置全局配置管理器(每个测试前)"""
from super_dev.config import manager
manager._global_config_manager = None
yield
manager._global_config_manager = None
@pytest.fixture
def temp_project_dir() -> Generator[Path, None, None]:
"""临时项目目录"""
temp_dir = Path(tempfile.mkdtemp())
yield temp_dir
shutil.rmtree(temp_dir, ignore_errors=True)
@pytest.fixture
def sample_config(temp_project_dir: Path) -> ProjectConfig:
"""示例配置"""
return ProjectConfig(
name="test-project",
description="Test project",
platform="web",
frontend="react",
backend="node",
domain="ecommerce"
)
@pytest.fixture
def config_manager(temp_project_dir: Path, sample_config: ProjectConfig) -> ConfigManager:
"""配置管理器"""
manager = ConfigManager(temp_project_dir)
manager._config = sample_config
return manager
@pytest.fixture
def workflow_engine(temp_project_dir: Path) -> WorkflowEngine:
"""工作流引擎"""
return WorkflowEngine(temp_project_dir)
@pytest.fixture
def workflow_context(temp_project_dir: Path, config_manager: ConfigManager) -> WorkflowContext:
"""工作流上下文"""
return WorkflowContext(
project_dir=temp_project_dir,
config=config_manager
)