Files
aiturk-hermes-ide/apps/desktop/assets/codex-bridge/test_is_hatti.py
T
yilsemandClaude Opus 5.5 48103b9ad3 feat(codex-bridge): the AITURK work line is part of Codex Baglama
The instruction is added for Codex Desktop whenever this computer has an AITURK
command that can send work (aiturk is); no separate switch, no bridge.json entry.
The bridge fills in the chat id; the command runs in Codex's own folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:31:49 +03:00

72 lines
3.6 KiB
Python

"""The "send larger work to AITURK" instruction reaches only Codex Desktop, and only when a send command exists."""
import unittest
import is_hatti as h
class Hat(unittest.TestCase):
def test_only_the_desktop_app_is_recognised(self):
self.assertTrue(h.masaustu_mu("Codex Desktop"))
for other in ("codex-tui", "codex_exec", "codex_cli_rs", "", None, "Codex Desktop Helper"):
self.assertFalse(h.masaustu_mu(other), other)
def test_no_instruction_when_switched_off_or_without_a_send_command(self):
self.assertIsNone(h.talimat(None))
self.assertIsNone(h.talimat({}))
self.assertIsNone(h.talimat({"enabled": True, "komut": " "}))
self.assertIsNone(h.talimat({"enabled": False, "komut": "aiturk gonder"}))
self.assertIsNone(h.talimat({"enabled": False}, "C:/a/aiturk.exe", "s1"))
text = h.talimat({"enabled": True, "komut": "aiturk gonder --dosya is.md"})
self.assertIn("aiturk gonder --dosya is.md", text)
self.assertIn("sen yap", text)
self.assertEqual(h.talimat({"enabled": True, "komut": "x", "talimat": "ozel {komut}"}), "ozel x")
def test_on_by_default_once_a_send_command_exists_on_this_computer(self):
text = h.talimat(None, "C:/Program/aiturk.exe", "019a-bc_d")
self.assertIn('"C:/Program/aiturk.exe" is --sohbet 019a-bc_d --dosya', text)
self.assertIn('"C:/Program/aiturk.exe" is --dosya', h.talimat({}, "C:/Program/aiturk.exe", ""))
# Sohbet kimligi komut satirina yazilir: kabuk karakteri tasiyamaz.
self.assertIn("--sohbet abrm-rf ", h.komut_satiri("x", 'a"b; rm -rf /'))
# Ayardaki komut bulunanin onune gecer.
self.assertIn("elle", h.talimat({"komut": "elle"}, "C:/Program/aiturk.exe"))
def test_the_first_candidate_that_knows_the_command_is_used(self):
import os
import tempfile
with tempfile.TemporaryDirectory() as d:
eski = os.path.join(d, "TurkServis", "AITURK", "program", "bin", "aiturk.cmd")
yeni = os.path.join(d, "TurkServis", "AITURK-is-hatti", "Scripts", "aiturk.exe")
for yol in (eski, yeni):
os.makedirs(os.path.dirname(yol))
open(yol, "w").close()
ortam = {"LOCALAPPDATA": d}
self.assertEqual(h.adaylar(ortam)[0], eski)
self.assertEqual(h.komut_bul(ortam, destek=lambda y: y == yeni), yeni)
self.assertEqual(h.komut_bul(ortam, destek=lambda y: True), eski)
self.assertIsNone(h.komut_bul(ortam, destek=lambda y: False))
class Sonuc:
returncode = 2
self.assertFalse(h.destekliyor(eski, calistir=lambda *a, **k: Sonuc()))
Sonuc.returncode = 0
self.assertTrue(h.destekliyor(eski, calistir=lambda *a, **k: Sonuc()))
self.assertFalse(h.destekliyor(os.path.join(d, "yok.exe"), calistir=lambda *a, **k: Sonuc()))
def patlar(*a, **k):
raise OSError("x")
self.assertFalse(h.destekliyor(eski, calistir=patlar))
def test_instruction_is_put_first_once_and_never_repeated(self):
req = {"input": [{"type": "message", "role": "user", "content": "selam"}]}
text = h.talimat({"enabled": True, "komut": "aiturk gonder"})
self.assertTrue(h.ekle(req, text))
self.assertEqual((req["input"][0]["role"], len(req["input"])), ("developer", 2))
self.assertFalse(h.ekle(req, text))
self.assertEqual(len(req["input"]), 2)
self.assertFalse(h.ekle({"input": "duz metin"}, text))
self.assertFalse(h.ekle(req, None))
if __name__ == "__main__":
unittest.main()