feat: release 2.4.0 with original cases and automatic human review
This commit is contained in:
1 parent
baf069854b
commit
4dc2057d43
66 files changed
+1390
-206
No files matched your search
@@ -57,10 +57,13 @@ def manifest_payload():
|
||||
}
|
||||
|
||||
|
||||
def install(plugins):
|
||||
def install(plugins, original_case=False):
|
||||
package = BytesIO()
|
||||
manifest = manifest_payload()
|
||||
if original_case:
|
||||
manifest["workspace"]["panels"][0]["kind"] = "original_case"
|
||||
with zipfile.ZipFile(package, "w") as archive:
|
||||
archive.writestr("plugin.json", json.dumps(manifest_payload()))
|
||||
archive.writestr("plugin.json", json.dumps(manifest))
|
||||
install_archive(plugins, package.getvalue())
|
||||
plugins.set_enabled("review", True)
|
||||
|
||||
@@ -105,6 +108,86 @@ def save(client, values, revision=0, request_id=None):
|
||||
)
|
||||
|
||||
|
||||
def test_original_case_import_requires_enabled_plugin_and_keeps_execution_prompt(context):
|
||||
from apps.admin_console.services import task_import
|
||||
|
||||
store, plugins, client = context
|
||||
legacy = load_workbook(BytesIO(task_import.template()))
|
||||
assert legacy["任务"].max_column == 7
|
||||
legacy["任务"].append(["OLD", "", "", "旧用例", "", "原样执行", ""])
|
||||
legacy_bytes = BytesIO()
|
||||
legacy.save(legacy_bytes)
|
||||
assert "original_case" not in task_import.parse_workbook(legacy_bytes.getvalue())["tasks"][0]
|
||||
|
||||
install(plugins, original_case=True)
|
||||
workbook = load_workbook(BytesIO(task_import.template()))
|
||||
assert [cell.value for cell in workbook["任务"][1]] == [
|
||||
*task_import.HEADERS,
|
||||
*task_import.CASE_HEADERS,
|
||||
]
|
||||
workbook["任务"].append(
|
||||
[
|
||||
"CASE-001",
|
||||
"检测项目",
|
||||
"测试子项",
|
||||
"测试标题",
|
||||
"提取的约束",
|
||||
"只执行此提示词",
|
||||
"{}",
|
||||
"原始预置条件",
|
||||
"1. 第一步\n2. 第二步",
|
||||
"原始预期结果",
|
||||
]
|
||||
)
|
||||
stream = BytesIO()
|
||||
workbook.save(stream)
|
||||
case = task_import.parse_workbook(stream.getvalue())["tasks"][0]
|
||||
assert task_import.case_goal(case) == "只执行此提示词"
|
||||
assert case["preconditions"] == "提取的约束"
|
||||
assert case["original_case"] == {
|
||||
"preconditions": "原始预置条件",
|
||||
"steps": "1. 第一步\n2. 第二步",
|
||||
"expected": "原始预期结果",
|
||||
}
|
||||
assert task_import.parse_workbook(legacy_bytes.getvalue())["valid"]
|
||||
store.save_job({"session_id": "task-one", "status": "completed", "case": case})
|
||||
result = client.get("/api/task-extensions/task-one").json()
|
||||
assert "CASE-001" in result["case_title"] and "测试标题" in result["case_title"]
|
||||
assert result["original_case"] == case["original_case"]
|
||||
assert result["initial_prompt"] == "只执行此提示词"
|
||||
assert report_export.session_report("task-one")["original_case"] == case["original_case"]
|
||||
|
||||
plugins.set_enabled("review", False)
|
||||
assert load_workbook(BytesIO(task_import.template()))["任务"].max_column == 7
|
||||
with pytest.raises(ValueError, match="列名或顺序"):
|
||||
task_import.parse_workbook(stream.getvalue())
|
||||
|
||||
|
||||
def test_review_navigation_uses_batch_order_and_excludes_unfinished_jobs(context):
|
||||
store, _, client = context
|
||||
store.create_batch({"id": "review-batch", "status": "completed"}, [], {})
|
||||
for position, status in [(3, "completed"), (1, "failed"), (2, "pending")]:
|
||||
store.save_job(
|
||||
{
|
||||
"session_id": f"batch-task-{position}",
|
||||
"batch_id": "review-batch",
|
||||
"position": position,
|
||||
"status": status,
|
||||
"case": {"name": f"用例{position}", "goal": "测试"},
|
||||
}
|
||||
)
|
||||
first = client.get("/api/task-extensions/batch-task-1").json()["navigation"]
|
||||
assert first == {
|
||||
"scope": "batch",
|
||||
"position": 1,
|
||||
"total": 2,
|
||||
"previous": None,
|
||||
"next": "batch-task-3",
|
||||
}
|
||||
last = client.get("/api/task-extensions/batch-task-3").json()["navigation"]
|
||||
assert last["previous"] == "batch-task-1" and last["next"] is None
|
||||
|
||||
|
||||
def test_workspace_requires_v3_and_valid_bounded_declarations():
|
||||
for change in (
|
||||
{"schema_version": 2},
|
||||
|
||||
Reference in new issue
Block a user