完善skills;测试用例生成页面功能初步实现
This commit is contained in:
@@ -51,6 +51,8 @@ class SRSTool:
|
||||
"other": "低",
|
||||
}
|
||||
|
||||
UNKNOWN_INTERFACE_VALUES = {"", "未知", "unknown", "n/a", "-", "--", "无", "none", "null"}
|
||||
|
||||
def __init__(self) -> None:
|
||||
ToolRegistry.register(self.DEFINITION)
|
||||
|
||||
@@ -90,24 +92,78 @@ class SRSTool:
|
||||
normalized: List[Dict[str, Any]] = []
|
||||
for index, req in enumerate(extracted, start=1):
|
||||
description = (req.description or "").strip()
|
||||
title = description[:40] if description else f"需求项 {index}"
|
||||
title = self._build_short_title(description, index)
|
||||
requirement_type = self._normalize_requirement_type(
|
||||
req_type=getattr(req, "type", "functional"),
|
||||
interface_name=getattr(req, "interface_name", ""),
|
||||
interface_type=getattr(req, "interface_type", ""),
|
||||
data_source=getattr(req, "source", ""),
|
||||
data_destination=getattr(req, "destination", ""),
|
||||
)
|
||||
source_field = f"{req.section_number} {req.section_title}".strip() or "文档解析"
|
||||
normalized.append(
|
||||
{
|
||||
"id": req.id,
|
||||
"title": title,
|
||||
"description": description,
|
||||
"priority": self.PRIORITY_BY_TYPE.get(req.type, "中"),
|
||||
"priority": "中",
|
||||
"acceptance_criteria": [description] if description else ["待补充验收标准"],
|
||||
"source_field": source_field,
|
||||
"section_uid": req.section_uid,
|
||||
"section_number": req.section_number,
|
||||
"section_title": req.section_title,
|
||||
"requirement_type": req.type,
|
||||
"requirement_type": requirement_type,
|
||||
"interface_name": req.interface_name if requirement_type == "interface" else "",
|
||||
"interface_type": req.interface_type if requirement_type == "interface" else "",
|
||||
"data_source": req.source if requirement_type == "interface" else "",
|
||||
"data_destination": req.destination if requirement_type == "interface" else "",
|
||||
"sort_order": index,
|
||||
}
|
||||
)
|
||||
return normalized
|
||||
|
||||
def _normalize_requirement_type(
|
||||
self,
|
||||
req_type: Any,
|
||||
interface_name: Any,
|
||||
interface_type: Any,
|
||||
data_source: Any,
|
||||
data_destination: Any,
|
||||
) -> str:
|
||||
raw_type = str(req_type or "").strip()
|
||||
mapping = {
|
||||
"功能需求": "functional",
|
||||
"接口需求": "interface",
|
||||
"性能需求": "performance",
|
||||
"安全需求": "security",
|
||||
"可靠性需求": "reliability",
|
||||
"其他需求": "other",
|
||||
}
|
||||
normalized_type = mapping.get(raw_type, raw_type)
|
||||
if normalized_type not in self.PRIORITY_BY_TYPE:
|
||||
normalized_type = "functional"
|
||||
|
||||
fields = [interface_name, interface_type, data_source, data_destination]
|
||||
has_interface_fields = any(
|
||||
str(value or "").strip().lower() not in self.UNKNOWN_INTERFACE_VALUES for value in fields
|
||||
)
|
||||
|
||||
if normalized_type == "interface" or has_interface_fields:
|
||||
return "interface"
|
||||
return normalized_type
|
||||
|
||||
def _build_short_title(self, description: str, index: int) -> str:
|
||||
text = (description or "").strip()
|
||||
if not text:
|
||||
return f"需求项 {index}"
|
||||
for separator in ("。", ";", "\n", ";", "."):
|
||||
if separator in text:
|
||||
text = text.split(separator, 1)[0].strip()
|
||||
break
|
||||
if len(text) <= 20:
|
||||
return text
|
||||
return f"{text[:20].rstrip()}"
|
||||
|
||||
def _load_config(self) -> Dict[str, Any]:
|
||||
config_path = Path(__file__).with_name("default_config.yaml")
|
||||
if config_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user