feat: connect django admin smoke tests
This commit is contained in:
+35
@@ -195,3 +195,38 @@
|
||||
- 阻塞:已解除。曾因 MySQL 用户缺少 `ALTER/INDEX/DROP` 等迁移权限受阻。
|
||||
- 决策:使用 PyMySQL 作为 MySQL 驱动;T-002 只落 apps、自定义 User、settings 与 MySQL 初始迁移,不提前实现 UserWallet/ApiKey 等 T-201 内容。
|
||||
- 下一步:领取 T-003 接通 django-admin 与最小测试。
|
||||
|
||||
## 2026-07-02 T-003 接通 django-admin 与最小测试
|
||||
|
||||
- 状态:PARTIAL
|
||||
- 变更:
|
||||
- `apps/users/admin.py`:用 `DjangoUserAdmin` 注册自定义 `User`,后台列表展示 `username/email/status/is_staff/is_active/created_at`,支持按 `status` 过滤、按 `username/email/payment_user_id` 搜索,`created_at` 只读。
|
||||
- `apps/users/tests.py`:新增最小 admin smoke test,覆盖自定义 User 已注册到 admin、superuser 可登录 `/admin/`。
|
||||
- `config/settings.py`:本地默认 `ALLOWED_HOSTS` 增加 `testserver`,匹配 Django test client。
|
||||
- `docs/06-tasks.md` / `docs/current-state.md`:记录 T-003 当前权限阻塞。
|
||||
- 验证:
|
||||
- `py -3.12 manage.py check`:通过,0 issues。
|
||||
- 手工创建临时 superuser 并用 Django test client 登录 `/admin/`:登录成功,`GET /admin/` 返回 200;临时用户已清理。
|
||||
- `py -3.12 manage.py test`:未通过,Django 在创建 `test_cmhub` 测试库时报 `(1044, "Access denied for user 'test'@'%' to database 'test_cmhub'")`。
|
||||
- 进一步验证 `CREATE DATABASE IF NOT EXISTS test_cmhub ...` 同样返回 1044;当前授权仅覆盖 `cmhub.*`。
|
||||
- 阻塞:需要给 MySQL 用户增加测试库权限,建议优先只授权测试库范围:
|
||||
- `GRANT ALL PRIVILEGES ON test_cmhub.* TO 'test'@'%';`
|
||||
- `FLUSH PRIVILEGES;`
|
||||
- 决策:不把 Django 测试改跑到业务库 `cmhub`,避免测试清表/迁移影响真实开发数据;T-003 在标准 `manage.py test` 通过前不标 `DONE`。
|
||||
- 下一步:完成 MySQL 授权后重跑 `py -3.12 manage.py test`,再跑 `py -3.12 manage.py check` / `./init.ps1`,通过后把 T-003 标记 DONE。
|
||||
|
||||
## 2026-07-02 T-003 接通 django-admin 与最小测试(完成验收)
|
||||
|
||||
- 状态:DONE
|
||||
- 变更:
|
||||
- `requirements.txt`:新增 `cryptography>=42,<47`,用于支持 PyMySQL 连接 MySQL 8 默认 `caching_sha2_password` 认证。
|
||||
- `docs/06-tasks.md`:T-003 从 BLOCKED 改为 DONE。
|
||||
- `docs/current-state.md` / `docs/03-tech-stack.md`:同步当前依赖、验证结果与下一步任务。
|
||||
- 验证:
|
||||
- `py -3.12 -m pip install -r requirements.txt`:通过,安装 `cryptography 46.0.7`。
|
||||
- `py -3.12 manage.py test`:通过,2 tests OK,测试库 `test_cmhub` 创建与销毁正常。
|
||||
- `py -3.12 manage.py check`:通过,0 issues。
|
||||
- `./init.ps1`:通过,依赖同步与基础检查正常。
|
||||
- 阻塞:无。
|
||||
- 决策:保留独立 `test_cmhub` 测试库路径,标准测试不使用业务库 `cmhub`。
|
||||
- 下一步:领取 T-101 Provider 适配器层 + 移植 cmbot 调用。
|
||||
|
||||
Reference in New Issue
Block a user