Skip to content

fix(antigravity): 修复 v1internal 模式检测逻辑并新增 E2E 测试;#234

Merged
ThreeFish-AI merged 4 commits into
feature/1.x.xfrom
ThreeFish-AI/e2e-antigravity-test
May 1, 2026
Merged

fix(antigravity): 修复 v1internal 模式检测逻辑并新增 E2E 测试;#234
ThreeFish-AI merged 4 commits into
feature/1.x.xfrom
ThreeFish-AI/e2e-antigravity-test

Conversation

@ThreeFish-AI
Copy link
Copy Markdown
Owner

@ThreeFish-AI ThreeFish-AI commented May 1, 2026

变更内容

1. v1internal 模式检测逻辑重构src/coding/proxy/vendors/antigravity.py

  • 引入 _v1internal_enabled 标志位,在 __init__ 时从 config.base_url 一次性判定模式,替代此前 _is_v1internal_mode()project_id AND URL 的双条件判断
  • 修复 __init__base_url/v1internal 后缀时 httpx 路径拼接重复问题:初始化时去除后缀,send_message / send_message_stream 端点改为完整路径 /v1internal:generateContent
  • _prepare_request 中的 project_id 自动发现守卫增加 _v1internal_enabled 跳过条件——v1internal 模式不依赖 project_id,无需触发 CRM API 发现流程

2. 新增 E2E 测试套件tests/e2e/

  • conftest.py:共享 fixtures——真实凭证加载、GLA/v1internal 双模式 Vendor 构建、FastAPI 应用与 HTTP 客户端
  • test_e2e_token.py(Level 1):Token 刷新、缓存、失效重试、错误凭证处理
  • test_e2e_vendor.py(Level 2):GLA 与 v1internal 模式的非流式/流式请求、system prompt、tools、project_id 自动发现
  • test_e2e_http.py(Level 3):完整 HTTP 端到端,模拟 Claude Code 通过 /v1/messages 的非流式/流式/tools/健康检查/状态诊断链路
  • 所有 E2E 测试通过 e2e marker 标记,默认排除,需 RUN_ANTIGRAVITY_E2E=1 环境变量激活

3. 配置与单元测试更新

  • pyproject.toml:新增 e2e marker 定义,默认 -m 'not e2e' 排除
  • tests/test_antigravity.py:同步更新 _is_v1internal_mode 相关断言,与新的 URL 驱动行为对齐

变更原因

原 v1internal 模式检测依赖 _effective_project_id AND "v1internal" in base_url 双条件,导致配置了 v1internal URL 但未显式设置 project_id 时模式被误判为未启用,project_id 发现守卫亦因此错误触发。v1internal 协议实际由 URL 路径决定,与 project_id 无关,需要将模式检测解耦。

测试计划

  • 单元测试 tests/test_antigravity.py 通过
  • E2E 测试:RUN_ANTIGRAVITY_E2E=1 uv run pytest tests/e2e/ -v(需真实凭证环境)

🤖 Generated with Claude Code, CodeX, Gemini

- 初始化时去除 base_url 的 /v1internal 后缀,避免 httpx 拼接时路径重复
- 新增 _v1internal_enabled 标志位,简化 v1internal 模式检测逻辑
- 修复端点路径为 /v1internal:generateContent 完整格式
- project_id 自动发现仅在标准 GLA 模式下触发,v1internal 模式跳过
- 同步更新单元测试断言,与重构后逻辑对齐

🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- 新增 tests/e2e/ 目录及 e2e pytest marker
- 默认测试运行排除 e2e 标记(-m 'not e2e'),需显式指定运行
- test_e2e_token.py: Token 获取与刷新流程验证
- test_e2e_vendor.py: Vendor 初始化与消息发送验证
- test_e2e_http.py: HTTP 请求/响应全链路验证
- conftest.py: 共享 fixture(配置加载、客户端初始化)

🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
@ThreeFish-AI ThreeFish-AI changed the title fix(antigravity): 修复 v1internal 模式检测逻辑并新增 E2E 测试 fix(antigravity): 修复 v1internal 模式检测逻辑并新增 E2E 测试; May 1, 2026
@ThreeFish-AI ThreeFish-AI merged commit 1be3817 into feature/1.x.x May 1, 2026
6 checks passed
@ThreeFish-AI ThreeFish-AI deleted the ThreeFish-AI/e2e-antigravity-test branch May 5, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant