Repository navigation
fix(automation):修正真实链路用例契约,门禁建表改用 create_all - #401
Merged
Merged
Conversation
added 2 commits
October 25, 2026 20:21
- `.github/workflows/ticket-gate.yml`:迁移步骤改为与 `test.yml` 一致的 `Base.metadata.create_all()`。原 `alembic upgrade head` 在 CI 空库上必然失败: baseline 迁移是空实现,且导入 `app` 会触发 `app/core/database.py` 模块级 `create_all`,导致后续 `ALTER TABLE permissions ADD COLUMN enabled` 撞车(1060)。 - `automation/tests/real/test_real_backend_smoke.py`:`POST /api/tasks` → `/api/tasks/`。真实路由带尾斜杠,不带斜杠返回 307,断言 200 必然失败。 - `automation/tests/real/test_ticket_lifecycle_real.py`:新增 `_user_id()`, `created_by` / `assigned_to` 改为比对 `users.id` 而非 username(真实契约存的是 `user_admin` 这类 id),派单参数同步改传 user id。 - `automation/docs/task-local-loop-verification.md`:新增本地真实环境闭环验证记录, 含搭建步骤、测试结果与 P0~P3 问题清单。 验证: - `pytest automation/tests -q` → 131 passed, 48 skipped - `pytest automation/src automation/config automation/ci_ai_gen -q` → 372 passed - `USE_MOCK=0 pytest automation/tests/real -q`(后端 8400 + MySQL 8.0.29)→ 4 passed
## 新增
`automation/tests/real/test_ticket_scenarios.py`(6 条,真实后端)
- 场景③-1 处理人不可撤回,仅提单人可撤回(403/200)
- 场景③-2 处理人请求暂停 → 提单人确认 → 已暂停
- 场景③-3 非处理中状态请求暂停 → 400
- 场景③-4 处理人请求无法解决 → 提单人确认 → 恢复处理
- 场景④ 非已解决不可打回(400),已解决可打回(200 → in_progress)
- 场景⑦ 添加评论 → 第三方可见 → 已读回执可查
覆盖代码中隐性必填字段:`pause_reason` / `unsolvable_reason` / `resolution_summary`。
## 修改
- `tests/real/test_ticket_lifecycle_real.py`:收尾不再 `DELETE`,改撤回。
- `docs/task-local-loop-verification.md`:P3 补充根因。
## 缺陷(自动化侧规避,需开发修)
`DELETE /api/tasks/{id}` 100% 返回 500:
```
(asyncmy.errors.IntegrityError) (1048, "Column 'task_id' cannot be null")
[SQL: UPDATE task_operation_logs SET task_id=%s ...]
```
删除逻辑试图把 `task_operation_logs.task_id` 置空,但该列 NOT NULL,导致任何
产生过操作日志的工单(建单即产生)都删不掉。用例清理因此改为撤回。
## 验证
- `USE_MOCK=0 pytest automation/tests/real -q` → 10 passed(真实耗时 291ms~35s)
- `pytest automation/tests -q` → 131 passed, 48 skipped
- 全量报告:146 条,139 passed / 7 skipped / 0 failed
Rosshow
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.github/workflows/ticket-gate.yml:迁移步骤改为与test.yml一致的Base.metadata.create_all()。原alembic upgrade head在 CI 空库上必然失败: baseline 迁移是空实现,且导入app会触发app/core/database.py模块级create_all,导致后续ALTER TABLE permissions ADD COLUMN enabled撞车(1060)。automation/tests/real/test_real_backend_smoke.py:POST /api/tasks→/api/tasks/。真实路由带尾斜杠,不带斜杠返回 307,断言 200 必然失败。automation/tests/real/test_ticket_lifecycle_real.py:新增_user_id(),created_by/assigned_to改为比对users.id而非 username(真实契约存的是user_admin这类 id),派单参数同步改传 user id。automation/docs/task-local-loop-verification.md:新增本地真实环境闭环验证记录, 含搭建步骤、测试结果与 P0~P3 问题清单。验证:
pytest automation/tests -q→ 131 passed, 48 skippedpytest automation/src automation/config automation/ci_ai_gen -q→ 372 passedUSE_MOCK=0 pytest automation/tests/real -q(后端 8400 + MySQL 8.0.29)→ 4 passed