source optimization
This commit is contained in:
parent
2d39197174
commit
c247a8f1dc
|
|
@ -17,5 +17,6 @@ class Config:
|
||||||
# HTTP测试配置
|
# HTTP测试配置
|
||||||
HTTP_BASE_URL: str = os.getenv("HTTP_BASE_URL", "http://localhost:8080")
|
HTTP_BASE_URL: str = os.getenv("HTTP_BASE_URL", "http://localhost:8080")
|
||||||
HTTP_TIMEOUT: int = 10
|
HTTP_TIMEOUT: int = 10
|
||||||
|
UNIT_KEYWORDS: tuple = ("units", "functions", "apis")
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
|
@ -2,7 +2,7 @@ import json
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
from gui_ai_developer.config import config
|
from config import config
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import json
|
||||||
import re
|
import re
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
from config import config
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════
|
||||||
# 基础数据结构
|
# 基础数据结构
|
||||||
|
|
@ -213,10 +213,17 @@ class InterfaceParser:
|
||||||
description="",
|
description="",
|
||||||
interfaces=self._parse_units(data),
|
interfaces=self._parse_units(data),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
units = []
|
||||||
|
for unit in config.UNIT_KEYWORDS:
|
||||||
|
if unit not in data:
|
||||||
|
continue
|
||||||
|
units = data.get(unit, [])
|
||||||
|
|
||||||
return ApiDescriptor(
|
return ApiDescriptor(
|
||||||
project=data.get("project", "default"),
|
project=data.get("project", "default"),
|
||||||
description=data.get("description", ""),
|
description=data.get("description", ""),
|
||||||
interfaces=self._parse_units(data.get("units", [])),
|
interfaces=self._parse_units(units),
|
||||||
)
|
)
|
||||||
|
|
||||||
# ── 单元解析 ──────────────────────────────────────────────
|
# ── 单元解析 ──────────────────────────────────────────────
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,8 @@ class PromptBuilder:
|
||||||
f"## Available Interfaces\n"
|
f"## Available Interfaces\n"
|
||||||
f"{json.dumps(iface_summary, ensure_ascii=False, indent=2)}\n\n"
|
f"{json.dumps(iface_summary, ensure_ascii=False, indent=2)}\n\n"
|
||||||
f"## Test Requirements\n"
|
f"## Test Requirements\n"
|
||||||
f"{req_lines}\n\n"
|
f"Generate comprehensive test cases (positive + negative) for every interface.\n"
|
||||||
f"Generate comprehensive test cases (positive + negative) for every requirement.\n"
|
f"- The generated test cases for each interface must meet the following requirements: {req_lines}\n"
|
||||||
f"- For function interfaces: use 'module_path' for import, "
|
f"- For function interfaces: use 'module_path' for import, "
|
||||||
f"'source_file' for reference.\n"
|
f"'source_file' for reference.\n"
|
||||||
f"- For HTTP interfaces: use 'full_url' as the request URL.\n"
|
f"- For HTTP interfaces: use 'full_url' as the request URL.\n"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import json
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from gui_ai_developer.config import config
|
from config import config
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import time
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from gui_ai_developer.config import config
|
from config import config
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
pip install -r requirements.txt
|
# pip install -r requirements.txt
|
||||||
|
|
||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
export LLM_API_KEY="sk-AUmOuFI731Ty5Nob38jY26d8lydfDT-QkE2giqb0sCuPCAE2JH6zjLM4lZLpvL5WMYPOocaMe2FwVDmqM_9KimmKACjR"
|
export LLM_API_KEY="sk-AUmOuFI731Ty5Nob38jY26d8lydfDT-QkE2giqb0sCuPCAE2JH6zjLM4lZLpvL5WMYPOocaMe2FwVDmqM_9KimmKACjR"
|
||||||
|
|
@ -15,5 +15,5 @@ export HTTP_BASE_URL="http://localhost:8080"
|
||||||
# --requirements "创建用户,自动生成测试数据,更改指定用户的密码,自动生成测试数据"
|
# --requirements "创建用户,自动生成测试数据,更改指定用户的密码,自动生成测试数据"
|
||||||
|
|
||||||
# 只生成不执行
|
# 只生成不执行
|
||||||
python main.py --api-desc examples/function_signatures.json \
|
python main.py --api-desc examples/api_desc.json \
|
||||||
--requirements "1.对每个接口进行测试,支持特殊值、边界值测试"
|
--requirements "1.对每个接口进行测试,支持特殊值、边界值测试"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue