34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from typing import Any
|
|
|
|
from beaver_agent.jobs.t3code import t3code_event
|
|
|
|
|
|
class FakeRun:
|
|
def __init__(self, payload: dict[str, Any]) -> None:
|
|
self.payload = payload
|
|
self.injects: list[tuple[str | None, str, str, str]] = []
|
|
|
|
async def inject_into(
|
|
self, public_id: str | None, text: str, *, urgency: str, origin: str
|
|
) -> bool:
|
|
self.injects.append((public_id, text, urgency, origin))
|
|
return True
|
|
|
|
|
|
async def test_the_event_goes_to_the_conversation_that_dispatched() -> None:
|
|
run = FakeRun(
|
|
{
|
|
"event": "completed",
|
|
"thread_id": "t1",
|
|
"title": "lint",
|
|
"machine": "mac",
|
|
"project": "beaver",
|
|
"origin": "conv-7",
|
|
"text": "done",
|
|
}
|
|
)
|
|
await t3code_event(run) # ty: ignore[invalid-argument-type]
|
|
[(target, text, urgency, origin)] = run.injects
|
|
assert (target, urgency, origin) == ("conv-7", "urgent", "t3code")
|
|
assert "завершён" in text and "done" in text
|