Files
Aether/tests/unit/test_gateway_tunnel_transport_stream_cleanup.py
fawney19 8f26e1a31f 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 服务层和测试适配新架构命名
2026-04-03 14:59:58 +08:00

42 lines
1.1 KiB
Python

from __future__ import annotations
import pytest
from src.services.proxy_node.gateway_tunnel_transport import TunnelRelayResponseStream
class _FakeResponse:
def __init__(self, chunks: list[bytes]) -> None:
self._chunks = chunks
self.closed = False
async def aiter_raw(self): # type: ignore[override]
for chunk in self._chunks:
yield chunk
async def aclose(self) -> None:
self.closed = True
@pytest.mark.asyncio
async def test_tunnel_relay_response_stream_closes_after_iteration() -> None:
response = _FakeResponse([b"hello", b"world"])
stream = TunnelRelayResponseStream(response) # type: ignore[arg-type]
chunks = []
async for chunk in stream:
chunks.append(chunk)
assert chunks == [b"hello", b"world"]
assert response.closed is True
@pytest.mark.asyncio
async def test_tunnel_relay_response_stream_aclose_closes_response() -> None:
response = _FakeResponse([])
stream = TunnelRelayResponseStream(response) # type: ignore[arg-type]
await stream.aclose()
assert response.closed is True