b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
import pytest
|
|
|
|
from gateway.config import GatewayConfig, Platform, PlatformConfig
|
|
from gateway.platforms.base import MessageEvent
|
|
from gateway.run import GatewayRunner
|
|
from gateway.session import SessionSource
|
|
|
|
|
|
def _make_runner(config: GatewayConfig) -> GatewayRunner:
|
|
runner = object.__new__(GatewayRunner)
|
|
runner.config = config
|
|
runner.adapters = {}
|
|
runner._model = "openai/gpt-4.1-mini"
|
|
runner._base_url = None
|
|
return runner
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_preprocess_prefixes_sender_for_shared_non_thread_group_session():
|
|
runner = _make_runner(
|
|
GatewayConfig(
|
|
platforms={
|
|
Platform.TELEGRAM: PlatformConfig(enabled=True, token="fake"),
|
|
},
|
|
group_sessions_per_user=False,
|
|
)
|
|
)
|
|
source = SessionSource(
|
|
platform=Platform.TELEGRAM,
|
|
chat_id="-1002285219667",
|
|
chat_name="Test Group",
|
|
chat_type="group",
|
|
user_name="Alice",
|
|
)
|
|
event = MessageEvent(text="hello", source=source)
|
|
|
|
result = await runner._prepare_inbound_message_text(
|
|
event=event,
|
|
source=source,
|
|
history=[],
|
|
)
|
|
|
|
assert result == "[Alice] hello"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_preprocess_keeps_plain_text_for_default_group_sessions():
|
|
runner = _make_runner(
|
|
GatewayConfig(
|
|
platforms={
|
|
Platform.TELEGRAM: PlatformConfig(enabled=True, token="fake"),
|
|
},
|
|
)
|
|
)
|
|
source = SessionSource(
|
|
platform=Platform.TELEGRAM,
|
|
chat_id="-1002285219667",
|
|
chat_name="Test Group",
|
|
chat_type="group",
|
|
user_name="Alice",
|
|
)
|
|
event = MessageEvent(text="hello", source=source)
|
|
|
|
result = await runner._prepare_inbound_message_text(
|
|
event=event,
|
|
source=source,
|
|
history=[],
|
|
)
|
|
|
|
assert result == "hello"
|