feat: telegram voice transcription (#74)
This commit is contained in:
@@ -128,6 +128,23 @@ async def test_run_allows_parallel_different_sessions() -> None:
|
||||
assert max_in_flight == 2
|
||||
|
||||
|
||||
def test_codex_exec_flags_after_exec() -> None:
|
||||
runner = CodexRunner(
|
||||
codex_cmd="codex",
|
||||
extra_args=["-c", "notify=[]", "--skip-git-repo-check"],
|
||||
)
|
||||
state = runner.new_state("hi", None)
|
||||
args = runner.build_args("hi", None, state=state)
|
||||
assert args == [
|
||||
"-c",
|
||||
"notify=[]",
|
||||
"exec",
|
||||
"--skip-git-repo-check",
|
||||
"--json",
|
||||
"-",
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_run_serializes_new_session_after_session_is_known(
|
||||
tmp_path, monkeypatch
|
||||
|
||||
@@ -106,6 +106,14 @@ class _FakeBot:
|
||||
_ = allowed_updates
|
||||
return []
|
||||
|
||||
async def get_file(self, file_id: str) -> dict | None:
|
||||
_ = file_id
|
||||
return None
|
||||
|
||||
async def download_file(self, file_path: str) -> bytes | None:
|
||||
_ = file_path
|
||||
return None
|
||||
|
||||
async def send_message(
|
||||
self,
|
||||
chat_id: int,
|
||||
@@ -386,6 +394,14 @@ async def test_telegram_transport_edit_wait_false_returns_ref() -> None:
|
||||
) -> list[dict] | None:
|
||||
return None
|
||||
|
||||
async def get_file(self, file_id: str) -> dict | None:
|
||||
_ = file_id
|
||||
return None
|
||||
|
||||
async def download_file(self, file_path: str) -> bytes | None:
|
||||
_ = file_path
|
||||
return None
|
||||
|
||||
async def send_message(
|
||||
self,
|
||||
chat_id: int,
|
||||
|
||||
@@ -22,6 +22,7 @@ def test_parse_incoming_update_maps_fields() -> None:
|
||||
assert msg.reply_to_message_id == 5
|
||||
assert msg.reply_to_text == "prev"
|
||||
assert msg.sender_id == 99
|
||||
assert msg.voice is None
|
||||
assert msg.raw == update["message"]
|
||||
|
||||
|
||||
@@ -38,10 +39,36 @@ def test_parse_incoming_update_filters_non_matching_chat() -> None:
|
||||
assert parse_incoming_update(update, chat_id=999) is None
|
||||
|
||||
|
||||
def test_parse_incoming_update_filters_non_text() -> None:
|
||||
def test_parse_incoming_update_filters_non_text_and_non_voice() -> None:
|
||||
update = {
|
||||
"update_id": 1,
|
||||
"message": {"message_id": 10, "chat": {"id": 123}},
|
||||
"message": {"message_id": 10, "chat": {"id": 123}, "photo": []},
|
||||
}
|
||||
|
||||
assert parse_incoming_update(update, chat_id=123) is None
|
||||
|
||||
|
||||
def test_parse_incoming_update_voice_message() -> None:
|
||||
update = {
|
||||
"update_id": 1,
|
||||
"message": {
|
||||
"message_id": 10,
|
||||
"chat": {"id": 123},
|
||||
"voice": {
|
||||
"file_id": "voice-id",
|
||||
"file_unique_id": "uniq",
|
||||
"duration": 3,
|
||||
"mime_type": "audio/ogg",
|
||||
"file_size": 1234,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
msg = parse_incoming_update(update, chat_id=123)
|
||||
assert msg is not None
|
||||
assert msg.text == ""
|
||||
assert msg.voice is not None
|
||||
assert msg.voice.file_id == "voice-id"
|
||||
assert msg.voice.mime_type == "audio/ogg"
|
||||
assert msg.voice.file_size == 1234
|
||||
assert msg.voice.duration == 3
|
||||
|
||||
@@ -92,6 +92,14 @@ class _FakeBot:
|
||||
self._updates_attempts += 1
|
||||
return []
|
||||
|
||||
async def get_file(self, file_id: str) -> dict | None:
|
||||
_ = file_id
|
||||
return None
|
||||
|
||||
async def download_file(self, file_path: str) -> bytes | None:
|
||||
_ = file_path
|
||||
return None
|
||||
|
||||
async def close(self) -> None:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user