mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
refactor: 移除独立 hub/proxy/executor/gateway crate,统一为 gateway tunnel 架构
- 删除 aether-hub、aether-proxy 独立项目及其 Dockerfile/配置 - 删除 crates/aether-executor 和 crates/aether-gateway 全部模块 - 新增 apps/ 目录作为应用入口 - 将 hub 概念重构为 gateway tunnel transport - 将 executor 重构为 execution runtime - 新增 tunnel.rs 合约定义和 testkit tunnel/execution_runtime 模块 - 更新 Python 服务层和测试适配新架构命名
This commit is contained in:
@@ -7,7 +7,7 @@ import httpx
|
||||
import pytest
|
||||
|
||||
import src.services.provider.adapters.antigravity.rust_http as antigravity_rust_http_mod
|
||||
import src.services.request.rust_executor_client as rust_client_mod
|
||||
import src.services.request.execution_runtime_client as runtime_client_mod
|
||||
from src.services.provider.adapters.antigravity.client import (
|
||||
fetch_available_models,
|
||||
load_code_assist,
|
||||
@@ -19,7 +19,7 @@ from src.services.provider.adapters.antigravity.constants import (
|
||||
PROD_BASE_URL,
|
||||
SANDBOX_BASE_URL,
|
||||
)
|
||||
from src.services.request.rust_executor_client import RustExecutorSyncResult
|
||||
from src.services.request.execution_runtime_client import ExecutionRuntimeSyncResult
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# load_code_assist
|
||||
@@ -88,10 +88,10 @@ async def test_load_code_assist_uses_rust_executor(
|
||||
) -> None:
|
||||
monkeypatch.setattr(antigravity_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={"cloudaicompanionProject": "project-rust"},
|
||||
@@ -110,7 +110,7 @@ async def test_load_code_assist_uses_rust_executor(
|
||||
data = await load_code_assist("tok", proxy_config=None, timeout_seconds=1.0)
|
||||
|
||||
assert data["cloudaicompanionProject"] == "project-rust"
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.url == f"{SANDBOX_BASE_URL}/v1internal:loadCodeAssist"
|
||||
assert plan.provider_api_format == "antigravity:load_code_assist"
|
||||
|
||||
@@ -176,10 +176,10 @@ async def test_fetch_available_models_uses_rust_executor(
|
||||
) -> None:
|
||||
monkeypatch.setattr(antigravity_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={"models": {"claude-sonnet-4": {"displayName": "Claude Sonnet 4"}}},
|
||||
@@ -203,7 +203,7 @@ async def test_fetch_available_models_uses_rust_executor(
|
||||
)
|
||||
|
||||
assert "models" in data
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.url == f"{DAILY_BASE_URL}/v1internal:fetchAvailableModels"
|
||||
assert plan.provider_api_format == "antigravity:fetch_available_models"
|
||||
assert plan.body.json_body == {"project": "project-1"}
|
||||
@@ -215,10 +215,10 @@ async def test_onboard_user_uses_rust_executor(
|
||||
) -> None:
|
||||
monkeypatch.setattr(antigravity_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={
|
||||
@@ -246,7 +246,7 @@ async def test_onboard_user_uses_rust_executor(
|
||||
)
|
||||
|
||||
assert project_id == "project-onboard"
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.url == f"{PROD_BASE_URL}/v1internal:onboardUser"
|
||||
assert plan.provider_api_format == "antigravity:onboard_user"
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ import httpx
|
||||
import pytest
|
||||
|
||||
import src.services.provider.adapters.gemini_cli.rust_http as gemini_cli_rust_http_mod
|
||||
import src.services.request.rust_executor_client as rust_client_mod
|
||||
import src.services.request.execution_runtime_client as runtime_client_mod
|
||||
from src.services.provider.adapters.gemini_cli.client import (
|
||||
load_code_assist,
|
||||
onboard_user,
|
||||
)
|
||||
from src.services.request.rust_executor_client import (
|
||||
RustExecutorClientError,
|
||||
RustExecutorSyncResult,
|
||||
from src.services.request.execution_runtime_client import (
|
||||
ExecutionRuntimeClientError,
|
||||
ExecutionRuntimeSyncResult,
|
||||
)
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ async def test_load_code_assist_uses_rust_executor(
|
||||
) -> None:
|
||||
monkeypatch.setattr(gemini_cli_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={"cloudaicompanionProject": "project-1"},
|
||||
@@ -42,7 +42,7 @@ async def test_load_code_assist_uses_rust_executor(
|
||||
result = await load_code_assist("access-token", proxy_config=None, timeout_seconds=12.0)
|
||||
|
||||
assert result["cloudaicompanionProject"] == "project-1"
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.method == "POST"
|
||||
assert plan.url.endswith("/v1internal:loadCodeAssist")
|
||||
assert plan.provider_api_format == "gemini_cli:load_code_assist"
|
||||
@@ -61,9 +61,9 @@ async def test_load_code_assist_falls_back_to_python_when_rust_unavailable(
|
||||
) -> None:
|
||||
monkeypatch.setattr(gemini_cli_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(side_effect=RustExecutorClientError("executor down")),
|
||||
AsyncMock(side_effect=ExecutionRuntimeClientError("executor down")),
|
||||
)
|
||||
fake_client = SimpleNamespace(
|
||||
post=AsyncMock(
|
||||
@@ -91,10 +91,10 @@ async def test_onboard_user_uses_rust_executor(
|
||||
) -> None:
|
||||
monkeypatch.setattr(gemini_cli_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={
|
||||
@@ -118,7 +118,7 @@ async def test_onboard_user_uses_rust_executor(
|
||||
)
|
||||
|
||||
assert project_id == "project-onboarded"
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.method == "POST"
|
||||
assert plan.url.endswith("/v1internal:onboardUser")
|
||||
assert plan.provider_api_format == "gemini_cli:onboard_user"
|
||||
|
||||
@@ -10,15 +10,15 @@ import pytest
|
||||
import src.services.provider.adapters.kiro.token_manager as token_manager_mod
|
||||
import src.services.provider.adapters.kiro.usage as usage_mod
|
||||
import src.services.provider.adapters.kiro.rust_http as kiro_rust_http_mod
|
||||
import src.services.request.rust_executor_client as rust_client_mod
|
||||
import src.services.request.execution_runtime_client as runtime_client_mod
|
||||
from src.services.provider.adapters.kiro.token_manager import (
|
||||
refresh_idc_token,
|
||||
refresh_social_token,
|
||||
)
|
||||
from src.services.provider.adapters.kiro.usage import fetch_kiro_usage_limits
|
||||
from src.services.request.rust_executor_client import (
|
||||
RustExecutorClientError,
|
||||
RustExecutorSyncResult,
|
||||
from src.services.request.execution_runtime_client import (
|
||||
ExecutionRuntimeClientError,
|
||||
ExecutionRuntimeSyncResult,
|
||||
)
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ async def test_fetch_kiro_usage_limits_uses_rust_executor(
|
||||
) -> None:
|
||||
monkeypatch.setattr(kiro_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={
|
||||
@@ -64,7 +64,7 @@ async def test_fetch_kiro_usage_limits_uses_rust_executor(
|
||||
|
||||
assert result["usage_data"]["desktopUserInfo"]["email"] == "kiro@example.com"
|
||||
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.method == "GET"
|
||||
assert "getUsageLimits" in plan.url
|
||||
assert plan.provider_api_format == "kiro:usage"
|
||||
@@ -77,9 +77,9 @@ async def test_fetch_kiro_usage_limits_falls_back_to_python_when_rust_unavailabl
|
||||
) -> None:
|
||||
monkeypatch.setattr(kiro_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(side_effect=RustExecutorClientError("executor down")),
|
||||
AsyncMock(side_effect=ExecutionRuntimeClientError("executor down")),
|
||||
)
|
||||
fake_client = SimpleNamespace(
|
||||
get=AsyncMock(
|
||||
@@ -120,10 +120,10 @@ async def test_refresh_social_token_uses_rust_executor(
|
||||
monkeypatch.setattr(kiro_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(time, "time", lambda: 1_000)
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={
|
||||
@@ -157,7 +157,7 @@ async def test_refresh_social_token_uses_rust_executor(
|
||||
assert new_cfg.access_token == "new-social-access-token"
|
||||
assert new_cfg.expires_at == 2800
|
||||
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.method == "POST"
|
||||
assert plan.url == "https://prod.us-east-1.auth.desktop.kiro.dev/refreshToken"
|
||||
assert plan.provider_api_format == "kiro:social_refresh"
|
||||
@@ -171,10 +171,10 @@ async def test_refresh_idc_token_uses_rust_executor(
|
||||
monkeypatch.setattr(kiro_rust_http_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(time, "time", lambda: 2_000)
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={
|
||||
@@ -209,7 +209,7 @@ async def test_refresh_idc_token_uses_rust_executor(
|
||||
assert new_cfg.access_token == "new-idc-access-token"
|
||||
assert new_cfg.expires_at == 5600
|
||||
|
||||
plan = rust_client_mod.RustExecutorClient.execute_sync_json.await_args.args[0]
|
||||
plan = runtime_client_mod.ExecutionRuntimeClient.execute_sync_json.await_args.args[0]
|
||||
assert plan.method == "POST"
|
||||
assert plan.url == "https://oidc.eu-west-1.amazonaws.com/token"
|
||||
assert plan.provider_api_format == "kiro:idc_refresh"
|
||||
|
||||
@@ -19,7 +19,7 @@ from src.services.provider_keys.quota_refresh.antigravity_refresher import (
|
||||
)
|
||||
from src.services.provider_keys.quota_refresh.codex_refresher import refresh_codex_key_quota
|
||||
from src.services.provider_keys.quota_refresh.kiro_refresher import refresh_kiro_key_quota
|
||||
from src.services.request.rust_executor_client import RustExecutorSyncResult
|
||||
from src.services.request.execution_runtime_client import ExecutionRuntimeSyncResult
|
||||
|
||||
|
||||
class _FakeDB:
|
||||
@@ -166,7 +166,7 @@ async def test_codex_refresher_prefers_rust_executor(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
from src.services.provider_keys.quota_refresh import codex_refresher as module
|
||||
from src.services.request import rust_executor_client as rust_module
|
||||
from src.services.request import execution_runtime_client as runtime_module
|
||||
|
||||
monkeypatch.setattr(app_config, "executor_backend", "rust")
|
||||
|
||||
@@ -200,15 +200,19 @@ async def test_codex_refresher_prefers_rust_executor(
|
||||
module, "parse_codex_wham_usage_response", lambda _data: {"used_percent": 12.5}
|
||||
)
|
||||
|
||||
async def _fake_execute_sync_json(self: object, plan: Any) -> RustExecutorSyncResult:
|
||||
async def _fake_execute_sync_json(self: object, plan: Any) -> ExecutionRuntimeSyncResult:
|
||||
captured["plan"] = plan
|
||||
return RustExecutorSyncResult(
|
||||
return ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={"ok": True},
|
||||
headers={"content-type": "application/json"},
|
||||
)
|
||||
|
||||
monkeypatch.setattr(rust_module.RustExecutorClient, "execute_sync_json", _fake_execute_sync_json)
|
||||
monkeypatch.setattr(
|
||||
runtime_module.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
_fake_execute_sync_json,
|
||||
)
|
||||
|
||||
result = await refresh_codex_key_quota(
|
||||
db=cast(Any, _FakeDB()),
|
||||
|
||||
@@ -14,7 +14,7 @@ from src.services.provider_ops.types import (
|
||||
ProviderActionType,
|
||||
ProviderOpsConfig,
|
||||
)
|
||||
from src.services.request.rust_executor_client import RustExecutorSyncResult
|
||||
from src.services.request.execution_runtime_client import ExecutionRuntimeSyncResult
|
||||
|
||||
|
||||
class _FakeDB:
|
||||
@@ -133,7 +133,7 @@ async def test_verify_auth_prefers_rust_executor(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
from src.services.provider_ops import service as module
|
||||
from src.services.request import rust_executor_client as rust_module
|
||||
from src.services.request import execution_runtime_client as runtime_module
|
||||
|
||||
service = ProviderOpsService(_FakeDB())
|
||||
architecture = _SuccessArchitecture()
|
||||
@@ -154,15 +154,19 @@ async def test_verify_auth_prefers_rust_executor(
|
||||
|
||||
captured: dict[str, Any] = {}
|
||||
|
||||
async def _fake_execute_sync_json(self: object, plan: Any) -> RustExecutorSyncResult:
|
||||
async def _fake_execute_sync_json(self: object, plan: Any) -> ExecutionRuntimeSyncResult:
|
||||
captured["plan"] = plan
|
||||
return RustExecutorSyncResult(
|
||||
return ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={"ok": True},
|
||||
headers={"content-type": "application/json"},
|
||||
)
|
||||
|
||||
monkeypatch.setattr(rust_module.RustExecutorClient, "execute_sync_json", _fake_execute_sync_json)
|
||||
monkeypatch.setattr(
|
||||
runtime_module.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
_fake_execute_sync_json,
|
||||
)
|
||||
|
||||
result = await service.verify_auth(
|
||||
base_url="https://example.com",
|
||||
|
||||
@@ -6,11 +6,11 @@ import pytest
|
||||
|
||||
import src.core.api_format.capabilities as capabilities_mod
|
||||
import src.services.model.upstream_fetcher as fetcher_mod
|
||||
import src.services.request.rust_executor_client as rust_client_mod
|
||||
import src.services.request.execution_runtime_client as runtime_client_mod
|
||||
from src.services.model.upstream_fetcher import fetch_models_from_endpoints
|
||||
from src.services.request.rust_executor_client import (
|
||||
RustExecutorClientError,
|
||||
RustExecutorSyncResult,
|
||||
from src.services.request.execution_runtime_client import (
|
||||
ExecutionRuntimeClientError,
|
||||
ExecutionRuntimeSyncResult,
|
||||
)
|
||||
|
||||
|
||||
@@ -34,13 +34,17 @@ async def test_fetch_models_from_endpoints_uses_rust_for_openai(
|
||||
AsyncMock(side_effect=AssertionError("python fallback should not run")),
|
||||
)
|
||||
execute_sync = AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={"data": [{"id": "gpt-5", "owned_by": "openai"}]},
|
||||
headers={"content-type": "application/json"},
|
||||
)
|
||||
)
|
||||
monkeypatch.setattr(rust_client_mod.RustExecutorClient, "execute_sync_json", execute_sync)
|
||||
monkeypatch.setattr(
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
execute_sync,
|
||||
)
|
||||
|
||||
models, errors, ok = await fetch_models_from_endpoints(
|
||||
[
|
||||
@@ -84,7 +88,7 @@ async def test_fetch_models_from_endpoints_uses_rust_for_claude_paginated(
|
||||
)
|
||||
execute_sync = AsyncMock(
|
||||
side_effect=[
|
||||
RustExecutorSyncResult(
|
||||
ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={
|
||||
"data": [{"id": "claude-sonnet-4"}],
|
||||
@@ -93,7 +97,7 @@ async def test_fetch_models_from_endpoints_uses_rust_for_claude_paginated(
|
||||
},
|
||||
headers={"content-type": "application/json"},
|
||||
),
|
||||
RustExecutorSyncResult(
|
||||
ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={
|
||||
"data": [{"id": "claude-opus-4"}],
|
||||
@@ -103,7 +107,11 @@ async def test_fetch_models_from_endpoints_uses_rust_for_claude_paginated(
|
||||
),
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(rust_client_mod.RustExecutorClient, "execute_sync_json", execute_sync)
|
||||
monkeypatch.setattr(
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
execute_sync,
|
||||
)
|
||||
|
||||
models, errors, ok = await fetch_models_from_endpoints(
|
||||
[
|
||||
@@ -149,7 +157,7 @@ async def test_fetch_models_from_endpoints_uses_rust_for_gemini(
|
||||
AsyncMock(side_effect=AssertionError("python fallback should not run")),
|
||||
)
|
||||
execute_sync = AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={
|
||||
"models": [
|
||||
@@ -162,7 +170,11 @@ async def test_fetch_models_from_endpoints_uses_rust_for_gemini(
|
||||
headers={"content-type": "application/json"},
|
||||
)
|
||||
)
|
||||
monkeypatch.setattr(rust_client_mod.RustExecutorClient, "execute_sync_json", execute_sync)
|
||||
monkeypatch.setattr(
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
execute_sync,
|
||||
)
|
||||
|
||||
models, errors, ok = await fetch_models_from_endpoints(
|
||||
[
|
||||
@@ -205,9 +217,9 @@ async def test_fetch_models_from_endpoints_returns_rust_only_error_when_rust_una
|
||||
lambda proxy_config, timeout=30.0: {"timeout": timeout},
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(side_effect=RustExecutorClientError("executor down")),
|
||||
AsyncMock(side_effect=ExecutionRuntimeClientError("executor down")),
|
||||
)
|
||||
python_fetch = AsyncMock(return_value=([{"id": "fallback-model"}], None))
|
||||
monkeypatch.setattr(capabilities_mod, "fetch_models_for_api_format", python_fetch)
|
||||
|
||||
@@ -7,9 +7,9 @@ import httpx
|
||||
import pytest
|
||||
|
||||
import src.services.task.video.cancel as cancel_mod
|
||||
import src.services.request.rust_executor_client as rust_client_mod
|
||||
import src.services.request.execution_runtime_client as runtime_client_mod
|
||||
from src.core.api_format.conversion.internal_video import VideoStatus
|
||||
from src.services.request.rust_executor_client import RustExecutorSyncResult
|
||||
from src.services.request.execution_runtime_client import ExecutionRuntimeSyncResult
|
||||
from src.services.task.video.cancel import VideoTaskCancelService
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ async def test_video_cancel_service_uses_rust_for_openai_delete(
|
||||
|
||||
monkeypatch.setattr(cancel_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=204,
|
||||
headers={},
|
||||
response_json=None,
|
||||
@@ -134,14 +134,18 @@ async def test_video_cancel_service_uses_rust_for_gemini_cancel(
|
||||
|
||||
monkeypatch.setattr(cancel_mod.config, "executor_backend", "rust")
|
||||
execute_sync = AsyncMock(
|
||||
return_value=RustExecutorSyncResult(
|
||||
return_value=ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
headers={"content-type": "application/json"},
|
||||
response_json={"ok": True},
|
||||
response_body_bytes=None,
|
||||
)
|
||||
)
|
||||
monkeypatch.setattr(rust_client_mod.RustExecutorClient, "execute_sync_json", execute_sync)
|
||||
monkeypatch.setattr(
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
execute_sync,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"src.core.crypto.crypto_service.decrypt",
|
||||
lambda value: "upstream-key",
|
||||
@@ -259,9 +263,9 @@ async def test_video_cancel_service_returns_503_when_rust_executor_unavailable(
|
||||
|
||||
monkeypatch.setattr(cancel_mod.config, "executor_backend", "rust")
|
||||
monkeypatch.setattr(
|
||||
rust_client_mod.RustExecutorClient,
|
||||
runtime_client_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
AsyncMock(side_effect=rust_client_mod.RustExecutorClientError("executor down")),
|
||||
AsyncMock(side_effect=runtime_client_mod.ExecutionRuntimeClientError("executor down")),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"src.core.crypto.crypto_service.decrypt",
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
from src.core.api_format.conversion.internal_video import InternalVideoPollResult, VideoStatus
|
||||
from src.models.database import VideoTask
|
||||
from src.services.request.rust_executor_client import RustExecutorSyncResult
|
||||
from src.services.request.execution_runtime_client import ExecutionRuntimeSyncResult
|
||||
from src.services.task.video.poller_adapter import VideoPollContext, VideoTaskPollerAdapter
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ async def test_update_task_after_poll_skips_terminal_cancelled_task(
|
||||
async def test_video_poller_try_rust_payload_passes_proxy_snapshot(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
from src.services.request import rust_executor_client as rust_mod
|
||||
from src.services.request import execution_runtime_client as runtime_mod
|
||||
from src.services.task.video import poller_adapter as mod
|
||||
|
||||
adapter = VideoTaskPollerAdapter()
|
||||
@@ -90,11 +90,18 @@ async def test_video_poller_try_rust_payload_passes_proxy_snapshot(
|
||||
proxy_snapshot = object()
|
||||
captured: dict[str, object] = {}
|
||||
|
||||
async def _fake_execute_sync_json(self: object, plan: object) -> RustExecutorSyncResult:
|
||||
async def _fake_execute_sync_json(self: object, plan: object) -> ExecutionRuntimeSyncResult:
|
||||
captured["plan"] = plan
|
||||
return RustExecutorSyncResult(status_code=200, response_json={"id": "op_1", "done": False})
|
||||
return ExecutionRuntimeSyncResult(
|
||||
status_code=200,
|
||||
response_json={"id": "op_1", "done": False},
|
||||
)
|
||||
|
||||
monkeypatch.setattr(rust_mod.RustExecutorClient, "execute_sync_json", _fake_execute_sync_json)
|
||||
monkeypatch.setattr(
|
||||
runtime_mod.ExecutionRuntimeClient,
|
||||
"execute_sync_json",
|
||||
_fake_execute_sync_json,
|
||||
)
|
||||
|
||||
ctx = VideoPollContext(
|
||||
task_id="task-1",
|
||||
|
||||
Reference in New Issue
Block a user