aitest-kit 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/PKG-INFO +1 -1
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/ir_renderer.py +5 -18
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/parser.py +2 -27
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/planner.py +7 -16
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/profile_validator.py +3 -3
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/project_config.py +21 -71
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/suite_target.py +0 -8
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/aitest.yaml +0 -2
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/refs/case-format.md +3 -6
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/refs/config-files.md +1 -3
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/emitter-build/SKILL.md +2 -2
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/emitter-build/refs/patterns.md +2 -2
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-codegen/SKILL.md +1 -1
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-codegen/refs/emitter_rules.md +1 -1
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-design/SKILL.md +1 -1
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-scaffold/refs/constraints.md +1 -1
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-scaffold/refs/formats.md +2 -2
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit.egg-info/PKG-INFO +1 -1
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit.egg-info/SOURCES.txt +1 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/pyproject.toml +1 -1
- aitest_kit-0.3.2/tests/test_codegen_parser.py +103 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_planner.py +7 -5
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_protocol_detection.py +12 -3
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_suite_profile.py +2 -2
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_workspace_config.py +34 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/LICENSE +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/README.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/cli.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/case_flow_planner.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/cli.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/emitter.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/explain.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/health.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/ir.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/module_type.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/profile.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/profile_merge.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/profile_schema.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/profile_validation_report.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/profile_variables.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/promotion.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/render_utils.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/structured_assertions.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/suite.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/codegen/suite_runner.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/doctor.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/helpers/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/helpers/grpc_ops.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/helpers/http.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/helpers/request_binding.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/helpers/structured_assertions.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/init_workspace.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/cli.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/loader.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/models.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/path_resolver.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/selection.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/registry/task_loader.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/classifier.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/cli.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/codegen_check.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/collector.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/paths.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/renderer.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/sanitizer.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/report/task_runner.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/runtime_variables.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/.gitignore +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/AGENTS.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/CLAUDE.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/README.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/__init__.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/refs/assertion-strategy.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/refs/l1-template.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/refs/l2-template.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/refs/mismatch-format.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/aitest_config/schemas/codegen_profile.schema.json +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/docs/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/README.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/case-migrate/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/doc-gen/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/doc-gen/refs/templates.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/doc-review/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/knowledge-build/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-codegen/refs/selector_reference.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-fix/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-maintain/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-maintain/refs/routing.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/skills/test-scaffold/SKILL.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/generated/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/knowledge/L0_system_architecture.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/knowledge/L1/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/knowledge/L2/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/knowledge/TEST_SPEC.md +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/plans/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/reports/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/results/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/suites/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/targets/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/templates/project_workspace/test_workspace/tasks/.gitkeep +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/upgrade_workspace.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/workspace.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit/workspace_config.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit.egg-info/dependency_links.txt +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit.egg-info/entry_points.txt +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit.egg-info/requires.txt +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/aitest_kit.egg-info/top_level.txt +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/setup.cfg +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_classifier.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_health_report.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_ir.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_profile_validator.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_promotion.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_promotion_reports.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_codegen_suite_target.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_collector.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_doctor.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_registry_contexts.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_registry_maintenance_cli.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_renderer.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_report_cli.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_runtime_variables.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_sanitizer.py +0 -0
- {aitest_kit-0.3.0 → aitest_kit-0.3.2}/tests/test_workspace_template.py +0 -0
|
@@ -45,7 +45,6 @@ class RenderedFile:
|
|
|
45
45
|
|
|
46
46
|
def _render_header(
|
|
47
47
|
ctx: EmitContext,
|
|
48
|
-
has_grpc: bool = False,
|
|
49
48
|
has_profile_variables: bool = False,
|
|
50
49
|
has_structured_assertions: bool = False,
|
|
51
50
|
) -> list[str]:
|
|
@@ -60,8 +59,6 @@ def _render_header(
|
|
|
60
59
|
])
|
|
61
60
|
if ctx.shared_config.base_request_http:
|
|
62
61
|
lines.append("from aitest_kit.helpers.request_binding import build_request")
|
|
63
|
-
if has_grpc:
|
|
64
|
-
lines.append(ctx.project.grpc_helper_import)
|
|
65
62
|
if has_profile_variables:
|
|
66
63
|
lines.append("from aitest_kit.runtime_variables import resolve_profile_variables")
|
|
67
64
|
if has_structured_assertions:
|
|
@@ -187,7 +184,7 @@ def _split_default_assertions(
|
|
|
187
184
|
case_ir: CaseIR,
|
|
188
185
|
ctx: EmitContext,
|
|
189
186
|
) -> tuple[list[AssertionIR], list[AssertionIR]]:
|
|
190
|
-
if case_ir.strategy
|
|
187
|
+
if case_ir.strategy != "default_http":
|
|
191
188
|
return [], case_ir.assertions
|
|
192
189
|
common_count = len(ctx.shared_config.common_assertions)
|
|
193
190
|
return case_ir.assertions[:common_count], case_ir.assertions[common_count:]
|
|
@@ -387,13 +384,10 @@ def _render_default_body(
|
|
|
387
384
|
|
|
388
385
|
req_call = _render_req_call(case_ir.request)
|
|
389
386
|
lines.append("")
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
f' resp = {case_ir.call.helper}({case_ir.call.target}, '
|
|
395
|
-
f'"{case_ir.call.api_path}", json={req_call})'
|
|
396
|
-
)
|
|
387
|
+
lines.append(
|
|
388
|
+
f' resp = {case_ir.call.helper}({case_ir.call.target}, '
|
|
389
|
+
f'"{case_ir.call.api_path}", json={req_call})'
|
|
390
|
+
)
|
|
397
391
|
|
|
398
392
|
common_assertions, case_assertions = _split_default_assertions(case_ir, ctx)
|
|
399
393
|
for cl in _render_assertions(common_assertions):
|
|
@@ -431,12 +425,6 @@ def render_file_from_ir(
|
|
|
431
425
|
) -> RenderedFile:
|
|
432
426
|
"""Render one pytest file from Case IR and parser case metadata."""
|
|
433
427
|
tc_by_id = {tc.id: tc for tc in test_cases}
|
|
434
|
-
has_grpc = any(
|
|
435
|
-
any("gRPC" in value for value in tc.scenario_vars.values())
|
|
436
|
-
for tc in test_cases
|
|
437
|
-
if not any("可行性存疑" in marker for marker in tc.markers)
|
|
438
|
-
)
|
|
439
|
-
|
|
440
428
|
all_lines: list[str] = []
|
|
441
429
|
skipped: list[tuple[str, str]] = []
|
|
442
430
|
skipped_meta: list[dict[str, Any]] = []
|
|
@@ -454,7 +442,6 @@ def render_file_from_ir(
|
|
|
454
442
|
|
|
455
443
|
all_lines.extend(_render_header(
|
|
456
444
|
ctx,
|
|
457
|
-
has_grpc=has_grpc,
|
|
458
445
|
has_profile_variables=has_profile_variables,
|
|
459
446
|
has_structured_assertions=has_structured_assertions,
|
|
460
447
|
))
|
|
@@ -15,7 +15,6 @@ from pathlib import Path
|
|
|
15
15
|
class SharedConfig:
|
|
16
16
|
interfaces: list[str] = field(default_factory=list)
|
|
17
17
|
base_request_http: dict | None = None
|
|
18
|
-
base_request_grpc: str | None = None
|
|
19
18
|
preconditions: list[str] = field(default_factory=list)
|
|
20
19
|
common_assertions: list[str] = field(default_factory=list)
|
|
21
20
|
variables: dict[str, str] = field(default_factory=dict)
|
|
@@ -99,26 +98,6 @@ def _find_template_placeholders(value: object, path: str = "$") -> list[str]:
|
|
|
99
98
|
return found
|
|
100
99
|
|
|
101
100
|
|
|
102
|
-
def _extract_text_block(lines: list[str], start: int) -> tuple[str | None, int]:
|
|
103
|
-
"""Extract a ```text ... ``` or ``` ... ``` code block."""
|
|
104
|
-
i = start
|
|
105
|
-
while i < len(lines):
|
|
106
|
-
stripped = lines[i].strip()
|
|
107
|
-
if stripped.startswith("```text") or (stripped == "```" and i > start):
|
|
108
|
-
break
|
|
109
|
-
if stripped.startswith("```") and not stripped.startswith("```json"):
|
|
110
|
-
break
|
|
111
|
-
i += 1
|
|
112
|
-
else:
|
|
113
|
-
return None, start
|
|
114
|
-
i += 1
|
|
115
|
-
text_lines = []
|
|
116
|
-
while i < len(lines) and not lines[i].strip().startswith("```"):
|
|
117
|
-
text_lines.append(lines[i])
|
|
118
|
-
i += 1
|
|
119
|
-
return "\n".join(text_lines), i + 1
|
|
120
|
-
|
|
121
|
-
|
|
122
101
|
# ---------------------------------------------------------------------------
|
|
123
102
|
# Shared config parsing
|
|
124
103
|
# ---------------------------------------------------------------------------
|
|
@@ -173,13 +152,10 @@ def _parse_shared_config(lines: list[str]) -> tuple[SharedConfig, int, list[str]
|
|
|
173
152
|
errors.append(_format_json_error("基础请求体(HTTP)", json_error))
|
|
174
153
|
continue
|
|
175
154
|
|
|
176
|
-
elif line.startswith("**基础请求体(gRPC)**") or line.startswith("**基础请求体(gRPC)**"):
|
|
177
|
-
text, i = _extract_text_block(lines, i + 1)
|
|
178
|
-
cfg.base_request_grpc = text
|
|
179
|
-
continue
|
|
180
|
-
|
|
181
155
|
elif line.startswith("**基础请求体"):
|
|
182
156
|
body, i, json_error = _extract_json_block(lines, i + 1)
|
|
157
|
+
if body is not None and cfg.base_request_http is None:
|
|
158
|
+
cfg.base_request_http = body
|
|
183
159
|
if body is None and json_error:
|
|
184
160
|
errors.append(_format_json_error(_shared_field_name(line), json_error))
|
|
185
161
|
continue
|
|
@@ -361,7 +337,6 @@ if __name__ == "__main__":
|
|
|
361
337
|
cfg = result.shared_config
|
|
362
338
|
print(f" Interfaces: {cfg.interfaces}")
|
|
363
339
|
print(f" HTTP body keys: {list(cfg.base_request_http.keys()) if cfg.base_request_http else 'None'}")
|
|
364
|
-
print(f" gRPC body: {'yes' if cfg.base_request_grpc else 'no'}")
|
|
365
340
|
print(f" Preconditions: {len(cfg.preconditions)}")
|
|
366
341
|
print(f" Common assertions: {cfg.common_assertions}")
|
|
367
342
|
print(f" Variables: {cfg.variables}")
|
|
@@ -89,17 +89,13 @@ def _strategy_for(
|
|
|
89
89
|
return "structured_case_flow", f"profile.case_flows.{tc.id}", "profile provides structured flow"
|
|
90
90
|
if _has_marker(tc, "manual"):
|
|
91
91
|
return "manual", "markers", "manual marker"
|
|
92
|
-
|
|
93
|
-
if is_grpc:
|
|
94
|
-
return "default_grpc", source, raw
|
|
95
|
-
return "default_http", "default", "no custom strategy or gRPC marker"
|
|
92
|
+
return "default_http", "default", "no custom strategy"
|
|
96
93
|
|
|
97
94
|
|
|
98
95
|
def _fixtures_for(
|
|
99
96
|
module: str,
|
|
100
97
|
tc: TestCase,
|
|
101
98
|
strategy: str,
|
|
102
|
-
protocol: str,
|
|
103
99
|
case_fixtures: dict[str, list[str]],
|
|
104
100
|
case_flows: dict[str, dict[str, Any]],
|
|
105
101
|
) -> tuple[list[str], str]:
|
|
@@ -116,8 +112,6 @@ def _fixtures_for(
|
|
|
116
112
|
return [], f"profile.case_flows.{tc.id}.fixture"
|
|
117
113
|
if strategy == "manual":
|
|
118
114
|
return [], "manual marker"
|
|
119
|
-
if protocol == "grpc":
|
|
120
|
-
return ["grpc_target", f"setup_{module}"], "default gRPC fixtures"
|
|
121
115
|
return ["http_base_url", f"setup_{module}"], "default HTTP fixtures"
|
|
122
116
|
|
|
123
117
|
|
|
@@ -198,11 +192,9 @@ def _request_patches_for(raw_patches: Any) -> list[RequestPatchIR]:
|
|
|
198
192
|
return patches
|
|
199
193
|
|
|
200
194
|
|
|
201
|
-
def _call_for(strategy: str,
|
|
195
|
+
def _call_for(strategy: str, project: ProjectConfig) -> CallIR | None:
|
|
202
196
|
if strategy in {"skipped", "custom_case_body", "structured_case_flow", "manual"}:
|
|
203
197
|
return None
|
|
204
|
-
if protocol == "grpc":
|
|
205
|
-
return CallIR(helper=project.grpc_helper_call, target="grpc_target")
|
|
206
198
|
return CallIR(
|
|
207
199
|
helper=project.helper_call,
|
|
208
200
|
target="http_base_url",
|
|
@@ -365,7 +357,7 @@ def _structured_assertions_for(
|
|
|
365
357
|
strategy: str,
|
|
366
358
|
structured_assertions: dict[str, list[dict[str, Any]]],
|
|
367
359
|
) -> list[AssertionIR]:
|
|
368
|
-
if strategy not in {"default_http", "
|
|
360
|
+
if strategy not in {"default_http", "structured_case_flow"}:
|
|
369
361
|
return []
|
|
370
362
|
templates = structured_assertions.get(tc.id, [])
|
|
371
363
|
result: list[AssertionIR] = []
|
|
@@ -382,7 +374,7 @@ def _structured_assertions_for(
|
|
|
382
374
|
|
|
383
375
|
def _case_diagnostics(case_ir: CaseIR, has_http_body: bool) -> list[DiagnosticIR]:
|
|
384
376
|
diagnostics: list[DiagnosticIR] = []
|
|
385
|
-
if case_ir.strategy
|
|
377
|
+
if case_ir.strategy == "default_http" and not has_http_body:
|
|
386
378
|
diagnostics.append(DiagnosticIR(
|
|
387
379
|
code="E202",
|
|
388
380
|
layer="planner",
|
|
@@ -468,12 +460,11 @@ def build_file_ir(
|
|
|
468
460
|
parse_result.module,
|
|
469
461
|
tc,
|
|
470
462
|
strategy,
|
|
471
|
-
protocol,
|
|
472
463
|
case_fixtures,
|
|
473
464
|
case_flows,
|
|
474
465
|
)
|
|
475
466
|
request_refs: set[str] = set()
|
|
476
|
-
if strategy
|
|
467
|
+
if strategy == "default_http":
|
|
477
468
|
request_refs.add(tc.id)
|
|
478
469
|
if strategy == "structured_case_flow":
|
|
479
470
|
request_refs.update(_request_refs_for_flow(case_flows.get(tc.id, {}), tc.id))
|
|
@@ -488,7 +479,7 @@ def build_file_ir(
|
|
|
488
479
|
request_bindings[request_case_id] = request_binding
|
|
489
480
|
|
|
490
481
|
request = request_bindings.get(tc.id)
|
|
491
|
-
call = _call_for(strategy,
|
|
482
|
+
call = _call_for(strategy, proj)
|
|
492
483
|
needed = _needed_variables(tc.assertions, parse_result.shared_config.variables)
|
|
493
484
|
variables = [
|
|
494
485
|
VariableIR(name=name, expression=proj.var_map[name], source="project_config.var_map")
|
|
@@ -569,7 +560,7 @@ def build_file_ir(
|
|
|
569
560
|
fixtures=fixtures,
|
|
570
561
|
setup_call=(
|
|
571
562
|
SetupCallIR(name=f"setup_{parse_result.module}", kwargs={"case_id": tc.id})
|
|
572
|
-
if strategy
|
|
563
|
+
if strategy == "default_http"
|
|
573
564
|
else None
|
|
574
565
|
),
|
|
575
566
|
request=request,
|
|
@@ -462,7 +462,7 @@ def _validate_structured_assertion_targets(
|
|
|
462
462
|
_error(
|
|
463
463
|
report,
|
|
464
464
|
"E530",
|
|
465
|
-
"structured_assertions only render for default_http
|
|
465
|
+
"structured_assertions only render for default_http "
|
|
466
466
|
"or structured_case_flow cases; use case_bodies or manual notes for "
|
|
467
467
|
f"{strategy} cases",
|
|
468
468
|
source,
|
|
@@ -493,11 +493,11 @@ def _strategy_name_for_case(
|
|
|
493
493
|
return "skipped"
|
|
494
494
|
if _case_has_marker(report, case_id, "manual"):
|
|
495
495
|
return "manual"
|
|
496
|
-
return "default_http
|
|
496
|
+
return "default_http"
|
|
497
497
|
|
|
498
498
|
|
|
499
499
|
def _allowed_structured_assertion_targets(strategy: str, flow: Any) -> set[str]:
|
|
500
|
-
if strategy == "default_http
|
|
500
|
+
if strategy == "default_http":
|
|
501
501
|
return {"resp"}
|
|
502
502
|
if strategy != "structured_case_flow":
|
|
503
503
|
return set()
|
|
@@ -30,10 +30,8 @@ class DefaultRequestConfig:
|
|
|
30
30
|
@dataclass
|
|
31
31
|
class ProjectConfig:
|
|
32
32
|
helper_import: str = "from aitest_kit.helpers import http as http_helper"
|
|
33
|
-
api_path: str = "/api/v1/
|
|
33
|
+
api_path: str = "/api/v1/replace-me"
|
|
34
34
|
helper_call: str = "http_helper.post"
|
|
35
|
-
grpc_helper_import: str = "from aitest_kit.helpers import grpc_ops"
|
|
36
|
-
grpc_helper_call: str = "grpc_ops.recommend"
|
|
37
35
|
var_map: dict[str, str] = field(default_factory=dict)
|
|
38
36
|
module_abbrevs: dict[str, str] = field(default_factory=dict)
|
|
39
37
|
builtin_assertion_rules: list[AssertionRule] = field(default_factory=list)
|
|
@@ -43,31 +41,14 @@ class ProjectConfig:
|
|
|
43
41
|
|
|
44
42
|
FALLBACK_PROJECT_CONFIG_DATA: dict[str, Any] = {
|
|
45
43
|
"helper_import": "from aitest_kit.helpers import http as http_helper",
|
|
46
|
-
"
|
|
47
|
-
"api_path": "/api/v1/recommend",
|
|
44
|
+
"api_path": "/api/v1/replace-me",
|
|
48
45
|
"helper_call": "http_helper.post",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"s": 'resp["results"][0]["score"]',
|
|
52
|
-
"cal": 'resp["results"][0]["calibrated_score"]',
|
|
53
|
-
},
|
|
54
|
-
"module_abbrevs": {
|
|
55
|
-
"calibration": "cal",
|
|
56
|
-
"ab_experiment": "ab",
|
|
57
|
-
"ab_service": "abs",
|
|
58
|
-
"feature_scoring": "feat",
|
|
59
|
-
"issuance": "issue",
|
|
60
|
-
"logging": "log",
|
|
61
|
-
"rough_ranking": "rank",
|
|
62
|
-
"scene_routing": "route",
|
|
63
|
-
"validation_ratelimit": "val",
|
|
64
|
-
"e2e": "e2e",
|
|
65
|
-
},
|
|
46
|
+
"var_map": {},
|
|
47
|
+
"module_abbrevs": {},
|
|
66
48
|
"module_types": {
|
|
67
|
-
"
|
|
68
|
-
"multi_endpoint": {"description": "
|
|
69
|
-
"
|
|
70
|
-
"isolated_service": {"description": "需要隔离服务实例", "requires": ["case_bodies"]},
|
|
49
|
+
"standard_http": {"description": "默认单接口 HTTP 模块"},
|
|
50
|
+
"multi_endpoint": {"description": "多端点或自定义流程模块", "requires": ["case_bodies"]},
|
|
51
|
+
"isolated_service": {"description": "需要隔离服务/运行时控制的模块", "requires": ["case_bodies"]},
|
|
71
52
|
},
|
|
72
53
|
"default_request": {
|
|
73
54
|
"auto_fields": {},
|
|
@@ -93,46 +74,6 @@ FALLBACK_PROJECT_CONFIG_DATA: dict[str, Any] = {
|
|
|
93
74
|
"regex": r"^response\.body\s*==\s*(?P<value>.+)",
|
|
94
75
|
"template": "assert resp == {value}",
|
|
95
76
|
},
|
|
96
|
-
{
|
|
97
|
-
"name": "coupon_null",
|
|
98
|
-
"regex": r"^(?:response\.body\.)?coupon\s*==\s*null$",
|
|
99
|
-
"template": 'assert resp["coupon"] is None',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"name": "coupon_top",
|
|
103
|
-
"regex": r"^(?=.*coupon\.item_id)(?=.*top_result).*$",
|
|
104
|
-
"template": 'assert resp["coupon"]["item_id"] == max(resp["results"], key=lambda r: r["score"])["item_id"]',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"name": "coupon_top_max",
|
|
108
|
-
"regex": r"^(?=.*coupon)(?=.*item_id)(?=.*max).*$",
|
|
109
|
-
"template": 'assert resp["coupon"]["item_id"] == max(resp["results"], key=lambda r: r["score"])["item_id"]',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"name": "set_match",
|
|
113
|
-
"regex": r"^set\(response\.(?P<path>.+?)\)\s*==\s*(?P<expected>\{.+\})$",
|
|
114
|
-
"template": "assert {result_set:path} == {expected}",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"name": "length",
|
|
118
|
-
"regex": r"^len\((?P<expr>.+?)\)\s*==\s*(?P<n>\d+)$",
|
|
119
|
-
"template": "assert len({expr}) == {n}",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"name": "linear_cal_with_b",
|
|
123
|
-
"regex": r"^cal\s*==\s*round\(clamp\((?P<k>[0-9.]+)\s*\*\s*s\s*\+\s*(?P<b>[0-9.]+)\)\s*,\s*4\)",
|
|
124
|
-
"template": "assert cal == pytest.approx(max(0, min(1, {k} * s + {b})), abs=1e-4)",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
"name": "linear_cal_no_b",
|
|
128
|
-
"regex": r"^cal\s*==\s*round\(clamp\((?P<k>[0-9.]+)\s*\*\s*s\)\s*,\s*4\)",
|
|
129
|
-
"template": "assert cal == pytest.approx(max(0, min(1, {k} * s)), abs=1e-4)",
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"name": "no_cal",
|
|
133
|
-
"regex": r"^cal\s*==\s*s\b.*$",
|
|
134
|
-
"template": "assert cal == pytest.approx(s)",
|
|
135
|
-
},
|
|
136
77
|
{
|
|
137
78
|
"name": "comparison",
|
|
138
79
|
"regex": r"^response\.(?:body\.)?(?P<path>\S+)\s*(?P<op>>=|<=|>|<)\s*(?P<value>.+)$",
|
|
@@ -175,16 +116,25 @@ def _default_request_from(raw: Any) -> DefaultRequestConfig:
|
|
|
175
116
|
|
|
176
117
|
|
|
177
118
|
def _project_from(data: dict[str, Any]) -> ProjectConfig:
|
|
119
|
+
var_map = data["var_map"] if isinstance(data.get("var_map"), dict) else FALLBACK_PROJECT_CONFIG_DATA["var_map"]
|
|
120
|
+
module_abbrevs = (
|
|
121
|
+
data["module_abbrevs"]
|
|
122
|
+
if isinstance(data.get("module_abbrevs"), dict)
|
|
123
|
+
else FALLBACK_PROJECT_CONFIG_DATA["module_abbrevs"]
|
|
124
|
+
)
|
|
125
|
+
module_types = (
|
|
126
|
+
data["module_types"]
|
|
127
|
+
if isinstance(data.get("module_types"), dict)
|
|
128
|
+
else FALLBACK_PROJECT_CONFIG_DATA["module_types"]
|
|
129
|
+
)
|
|
178
130
|
return ProjectConfig(
|
|
179
131
|
helper_import=data.get("helper_import", FALLBACK_PROJECT_CONFIG_DATA["helper_import"]),
|
|
180
132
|
api_path=data.get("api_path", FALLBACK_PROJECT_CONFIG_DATA["api_path"]),
|
|
181
133
|
helper_call=data.get("helper_call", FALLBACK_PROJECT_CONFIG_DATA["helper_call"]),
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
var_map=dict(data.get("var_map") or FALLBACK_PROJECT_CONFIG_DATA["var_map"]),
|
|
185
|
-
module_abbrevs=dict(data.get("module_abbrevs") or FALLBACK_PROJECT_CONFIG_DATA["module_abbrevs"]),
|
|
134
|
+
var_map=dict(var_map),
|
|
135
|
+
module_abbrevs=dict(module_abbrevs),
|
|
186
136
|
builtin_assertion_rules=_rules_from(data.get("builtin_assertion_rules")),
|
|
187
|
-
module_types=dict(
|
|
137
|
+
module_types=dict(module_types),
|
|
188
138
|
default_request=_default_request_from(data.get("default_request")),
|
|
189
139
|
)
|
|
190
140
|
|
|
@@ -29,14 +29,6 @@ def project_config_for_suite_target(context: SuiteContext, project: ProjectConfi
|
|
|
29
29
|
)
|
|
30
30
|
if http_import:
|
|
31
31
|
updates["helper_import"] = http_import
|
|
32
|
-
grpc_import = _target_helper_import(
|
|
33
|
-
helper_dir,
|
|
34
|
-
module_name="grpc_ops",
|
|
35
|
-
import_clause="grpc_ops",
|
|
36
|
-
workspace_root=target_context.workspace_root,
|
|
37
|
-
)
|
|
38
|
-
if grpc_import:
|
|
39
|
-
updates["grpc_helper_import"] = grpc_import
|
|
40
32
|
return replace(project, **updates) if updates else project
|
|
41
33
|
|
|
42
34
|
|
|
@@ -13,10 +13,8 @@ workspace:
|
|
|
13
13
|
refs_dir: aitest_config/refs
|
|
14
14
|
codegen:
|
|
15
15
|
helper_import: from aitest_kit.helpers import http as http_helper
|
|
16
|
-
grpc_helper_import: from aitest_kit.helpers import grpc_ops
|
|
17
16
|
api_path: /api/v1/replace-me
|
|
18
17
|
helper_call: http_helper.post
|
|
19
|
-
grpc_helper_call: grpc_ops.call
|
|
20
18
|
var_map: {}
|
|
21
19
|
module_abbrevs: {}
|
|
22
20
|
module_types:
|
|
@@ -27,11 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
**接口**:`POST /api/v1/recommend` / `gRPC coupon.CouponService/Recommend`
|
|
29
29
|
|
|
30
|
-
**基础请求体(
|
|
31
|
-
(完整、合法的 JSON
|
|
32
|
-
|
|
33
|
-
**基础请求体(gRPC)**:
|
|
34
|
-
(完整 protobuf message 字段,如有两种接口)
|
|
30
|
+
**基础请求体(JSON)**:
|
|
31
|
+
(完整、合法的 JSON。也兼容 `基础请求体` / `基础请求体(HTTP)` / `基础请求体(gRPC)` 写法;变化字段写合法默认值,不使用 `{{placeholder}}`;默认请求路线和 `case_flow` 的 `request_ref` 都通过 suite profile 的 `requests` 替换字段;`基础请求体(gRPC)` 只作为兼容标签,不代表存在 `default_grpc`)
|
|
35
32
|
|
|
36
33
|
**标准前置**:
|
|
37
34
|
- 所有用例共用的环境准备步骤(路由配置、库存初始化等)
|
|
@@ -75,7 +72,7 @@
|
|
|
75
72
|
| 字段 | 必填 | 说明 |
|
|
76
73
|
|------|------|------|
|
|
77
74
|
| 接口 | 是 | 列出模块暴露的所有接口类型(HTTP endpoint + gRPC method) |
|
|
78
|
-
| 基础请求体 |
|
|
75
|
+
| 基础请求体 | 默认 HTTP 路线和 `case_flow.request_ref` 必填 | 完整的 JSON 请求体;可写 `基础请求体` / `基础请求体(JSON)` / `基础请求体(HTTP)` / `基础请求体(gRPC)`,不允许 `{{var}}` 占位符。所有标签都会统一解析为 JSON 基础请求体;`基础请求体(gRPC)` 只是兼容标签,不代表存在 `default_grpc`。不使用 `request_ref` 的 gRPC、SDK、多端点或全部由 `case_flows/case_bodies` 覆盖的用例不依赖默认请求体 |
|
|
79
76
|
| 标准前置 | 是 | 所有用例共用的环境准备(路由表、库存、基础配置等) |
|
|
80
77
|
| 通用断言 | 是 | 每条用例都要检查的断言 |
|
|
81
78
|
| 变量定义 | 按需 | 关系断言中的变量缩写,减少每条用例的重复 |
|
|
@@ -82,10 +82,8 @@ workspace:
|
|
|
82
82
|
|
|
83
83
|
codegen:
|
|
84
84
|
helper_import: from aitest_kit.helpers import http as http_helper
|
|
85
|
-
grpc_helper_import: from aitest_kit.helpers import grpc_ops
|
|
86
85
|
api_path: /api/v1/replace-me
|
|
87
86
|
helper_call: http_helper.post
|
|
88
|
-
grpc_helper_call: grpc_ops.call
|
|
89
87
|
default_request:
|
|
90
88
|
auto_fields: {}
|
|
91
89
|
module_types:
|
|
@@ -361,7 +359,7 @@ structured_assertions:
|
|
|
361
359
|
|
|
362
360
|
`structured_assertions` 规则:
|
|
363
361
|
|
|
364
|
-
- default HTTP
|
|
362
|
+
- default HTTP 路线只能写 `target: resp`。
|
|
365
363
|
- `case_flow` 路线只能写当前 flow 中 `save_as` 或 `assign` 产出的变量。
|
|
366
364
|
- `case_bodies`、pure manual、skipped 用例不写 `structured_assertions`。
|
|
367
365
|
- JSONPath、集合遍历、字段存在性和长度断言优先写 `structured_assertions`。
|
|
@@ -60,7 +60,7 @@ effort: high
|
|
|
60
60
|
|
|
61
61
|
| strategy | 处理方向 |
|
|
62
62
|
|---|---|
|
|
63
|
-
| `default_http`
|
|
63
|
+
| `default_http` | 提取 assertion_rules 或默认请求规则 |
|
|
64
64
|
| `structured_case_flow` | 对齐 flow,寻找可抽 helper 或更通用 flow 模式 |
|
|
65
65
|
| `custom_case_body` | 分析是否保留 body、抽 helper 或晋升 flow |
|
|
66
66
|
| `manual` | pure manual 不写 flow;半自动可保留 flow/body |
|
|
@@ -134,7 +134,7 @@ effort: high
|
|
|
134
134
|
|
|
135
135
|
分析结果:
|
|
136
136
|
- 总 case:{total}
|
|
137
|
-
- default_http
|
|
137
|
+
- default_http:{N}
|
|
138
138
|
- case_flows:{N}
|
|
139
139
|
- case_bodies:{N}
|
|
140
140
|
- manual:{N}
|
|
@@ -108,12 +108,12 @@ assertion_rules:
|
|
|
108
108
|
| `promote_to_structured_assertions` | JSONPath、集合遍历、字段存在性、长度断言重复出现 | suite profile |
|
|
109
109
|
| `promote_to_case_flow` | 多步骤流程稳定,差异主要是参数和期望值 | suite profile |
|
|
110
110
|
| `promote_to_helper` | 多个 body/flow 重复 Python 逻辑 | fixture/helper |
|
|
111
|
-
| `promote_to_default_template` | 可退回 default_http
|
|
111
|
+
| `promote_to_default_template` | 可退回 default_http,且默认模板真实适配 | suite profile requests |
|
|
112
112
|
| `keep_case_body` | 少见、复杂、并发、mock 等暂不晋升 | suite profile |
|
|
113
113
|
|
|
114
114
|
推荐顺序:structured_assertions / assertion_rule → case_flow → fixture/helper → keep_case_body → emitter/renderer 规则最后。
|
|
115
115
|
|
|
116
|
-
不要因为 default_http
|
|
116
|
+
不要因为 default_http 已存在就强行退回默认模板;gRPC、多端点、SDK 项目通常应优先使用 fixture Client + case_flow。
|
|
117
117
|
|
|
118
118
|
## 晋升条件
|
|
119
119
|
|
|
@@ -170,7 +170,7 @@ python3 -m aitest_kit.cli codegen --suite-file <suite_dir>/suite.yaml --check
|
|
|
170
170
|
|
|
171
171
|
profile 硬门禁有 ERROR 时不进入 IR/emitter,先修 profile。`profile not found`、占位路径、`--check stale` 都是回灌未完成信号。
|
|
172
172
|
|
|
173
|
-
Case IR strategy 覆盖:`default_http`、`
|
|
173
|
+
Case IR strategy 覆盖:`default_http`、`custom_case_body`、`structured_case_flow`、`manual`、`skipped`。写 `协议:gRPC` 或 `基础请求体(gRPC)` 不会阻断默认 JSON 路径;真实 gRPC、SDK、多端点或自定义动作库调用再通过 `case_flows` 或 `case_bodies` 显式接线。CLI 支持 `--explain`/`--dump-ir` 时优先用它们排查:单条 case 先看 `--explain <TC-ID>` 的 Strategy、Case flow、Request bindings、Request review、Assertions、Review hint;需要机器可读全量信息时再看 `--dump-ir`。
|
|
174
174
|
|
|
175
175
|
检查输出摘要和 `--health-report` 中的 UNPARSED、case_body、manual、structured_assertion_target_counts、request_binding_counts、profile_variable_counts、review_focus、next_actions,确认每条 case 的 strategy/protocol/fixtures/request binding 与预期一致。
|
|
176
176
|
|
|
@@ -75,7 +75,7 @@ target/suite 模式下,fixture 由 `test_workspace/targets/{target}/fixtures/{
|
|
|
75
75
|
## 结构化断言
|
|
76
76
|
|
|
77
77
|
- JSONPath、列表遍历、字段存在性和长度断言优先写 suite profile `structured_assertions`。
|
|
78
|
-
- default HTTP
|
|
78
|
+
- default HTTP 路线的 `target` 只能是 `resp`。
|
|
79
79
|
- `case_flow` 路线的 `target` 必须来自当前 flow 中的 `save_as` 或 `assign`。
|
|
80
80
|
- `case_bodies`、pure manual、skipped 用例不挂 `structured_assertions`。
|
|
81
81
|
- 复杂业务公式、循环、条件、等待和跨响应计算应封装到 fixture/helper 方法,再用 `case_flow.call` 调用;不要把 YAML 写成控制流语言。
|
|
@@ -79,7 +79,7 @@ effort: high
|
|
|
79
79
|
10. 区分可控输入与系统中间产物:请求参数、配置、测试数据、外部依赖状态属于可控输入,可在前置条件中指定具体值;系统运行时计算结果(如派生值、聚合值、排序位次)属于中间产物,不能在前置条件或场景变量中假设其具体值,只能通过调整可控输入间接影响;对中间产物的断言必须使用范围断言或关系断言
|
|
80
80
|
11. 断言选择遵循 `aitest_config/refs/assertion-strategy.md` 的三种策略
|
|
81
81
|
|
|
82
|
-
**接口覆盖**:查看 L1 "接口"章节,确认模块暴露的接口类型(HTTP / gRPC /
|
|
82
|
+
**接口覆盖**:查看 L1 "接口"章节,确认模块暴露的接口类型(HTTP / gRPC / 两者)。共享配置可以列出多种接口,但默认 Markdown 用例只生成 JSON 基础请求体;写 `协议:gRPC` 或 `基础请求体(gRPC)` 不会阻断默认 JSON 路径,真实 gRPC、SDK 或多端点执行再在后续 suite profile 中通过 `case_flows` 或 `case_bodies` 显式接线。
|
|
83
83
|
|
|
84
84
|
**输出格式**:默认输出到 `$suite_dir/business.md`;如果用户指定需求 suite,可输出为 `{suite_name}_business.md` 等带语义的文件名。按 `aitest_config/refs/case-format.md` 的"共享配置 + 精简用例"格式。每条用例只写 **优先级 / 场景变量 / 断言** 三个字段(有特殊状态时加 **标记** 字段)。场景变量必须写成 `key:value` 条目列表,`[manual]`、`[!可行性存疑]` 等标记写在独立的标记字段,不内联到场景变量或断言中。test-design 只产出 Markdown 用例,不写 `suite.yaml` 和 suite profile;这些由 `test-scaffold` / `test-codegen` 接线。
|
|
85
85
|
|
|
@@ -207,7 +207,7 @@ case_bodies:
|
|
|
207
207
|
- `requests.patches` 使用 JSON Patch 子集:`add` / `replace` / `remove`。`add/replace` 必须且只能写 `value` 或 `value_from`;`remove` 不写值。`value_from` 引用 `variables.defaults` 或 `variables.cases.<case_id>`。
|
|
208
208
|
- `overrides` 只适合简单字段覆盖;涉及 list 追加/指定位置、删除字段、dict 整体替换或变量注入时使用 `patches`。
|
|
209
209
|
- 集合遍历、JSONPath、字段存在性和长度断言优先写 `structured_assertions`,不要为了这类断言升级成 `case_body`。
|
|
210
|
-
- default HTTP
|
|
210
|
+
- default HTTP 路线的 `structured_assertions.target` 只能写 `resp`;case_flow 路线只能写当前 flow 中 `save_as` 或 `assign` 产出的变量。
|
|
211
211
|
- 复杂业务计算、循环/条件/等待逻辑封装到 fixture/helper 方法,再由 `case_flow.call` 调用;不要扩展 YAML 控制流。
|
|
212
212
|
- 非 manual 用例的 `case_flow` 至少包含一个 `call` 或 `assert`;纯人工 `[manual]` 不写 flow,半自动 manual 才写带 `call/assert` 的 flow。
|
|
213
213
|
- `{case_id}` 会由 codegen 替换成当前用例 ID。
|
|
@@ -266,7 +266,7 @@ Client 方法:
|
|
|
266
266
|
- {method_name}({params}) [auth: yes/no]
|
|
267
267
|
|
|
268
268
|
路线分布:
|
|
269
|
-
- default_http
|
|
269
|
+
- default_http:{N} 条
|
|
270
270
|
- structured_case_flow:{N} 条
|
|
271
271
|
- custom_case_body:{N} 条(附保留原因)
|
|
272
272
|
- manual:{N} 条
|
|
@@ -107,6 +107,7 @@ aitest_kit/templates/project_workspace/test_workspace/tasks/.gitkeep
|
|
|
107
107
|
tests/test_classifier.py
|
|
108
108
|
tests/test_codegen_health_report.py
|
|
109
109
|
tests/test_codegen_ir.py
|
|
110
|
+
tests/test_codegen_parser.py
|
|
110
111
|
tests/test_codegen_planner.py
|
|
111
112
|
tests/test_codegen_profile_validator.py
|
|
112
113
|
tests/test_codegen_promotion.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aitest-kit"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "AI-assisted testing toolchain: docs → knowledge base → Markdown cases → pytest code → structured reports"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|