mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
- 删除 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 服务层和测试适配新架构命名
42 lines
1.1 KiB
Python
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
|