mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
feat: fix img pasting in new ink plus newline after tools
This commit is contained in:
@@ -250,6 +250,15 @@ class TestWslHasImage:
|
||||
mock_run.return_value = MagicMock(stdout="False\n", returncode=0)
|
||||
assert _wsl_has_image() is False
|
||||
|
||||
def test_falls_back_to_get_clipboard_image(self):
|
||||
with patch("hermes_cli.clipboard.subprocess.run") as mock_run:
|
||||
mock_run.side_effect = [
|
||||
MagicMock(stdout="False\n", returncode=0),
|
||||
MagicMock(stdout="True\n", returncode=0),
|
||||
]
|
||||
assert _wsl_has_image() is True
|
||||
assert mock_run.call_count == 2
|
||||
|
||||
def test_powershell_not_found(self):
|
||||
with patch("hermes_cli.clipboard.subprocess.run", side_effect=FileNotFoundError):
|
||||
assert _wsl_has_image() is False
|
||||
@@ -269,6 +278,18 @@ class TestWslSave:
|
||||
assert _wsl_save(dest) is True
|
||||
assert dest.read_bytes() == FAKE_PNG
|
||||
|
||||
def test_falls_back_to_get_clipboard_extraction(self, tmp_path):
|
||||
dest = tmp_path / "out.png"
|
||||
b64_png = base64.b64encode(FAKE_PNG).decode()
|
||||
with patch("hermes_cli.clipboard.subprocess.run") as mock_run:
|
||||
mock_run.side_effect = [
|
||||
MagicMock(stdout="", returncode=1),
|
||||
MagicMock(stdout=b64_png + "\n", returncode=0),
|
||||
]
|
||||
assert _wsl_save(dest) is True
|
||||
assert mock_run.call_count == 2
|
||||
assert dest.read_bytes() == FAKE_PNG
|
||||
|
||||
def test_no_image_returns_false(self, tmp_path):
|
||||
dest = tmp_path / "out.png"
|
||||
with patch("hermes_cli.clipboard.subprocess.run") as mock_run:
|
||||
@@ -528,6 +549,16 @@ class TestWindowsHasImage:
|
||||
mock_run.return_value = MagicMock(stdout="False\n", returncode=0)
|
||||
assert _windows_has_image() is False
|
||||
|
||||
def test_falls_back_to_get_clipboard_image(self):
|
||||
with patch("hermes_cli.clipboard._get_ps_exe", return_value="powershell"):
|
||||
with patch("hermes_cli.clipboard.subprocess.run") as mock_run:
|
||||
mock_run.side_effect = [
|
||||
MagicMock(stdout="False\n", returncode=0),
|
||||
MagicMock(stdout="True\n", returncode=0),
|
||||
]
|
||||
assert _windows_has_image() is True
|
||||
assert mock_run.call_count == 2
|
||||
|
||||
def test_no_powershell_available(self):
|
||||
with patch("hermes_cli.clipboard._get_ps_exe", return_value=None):
|
||||
assert _windows_has_image() is False
|
||||
@@ -559,6 +590,20 @@ class TestWindowsSave:
|
||||
assert _windows_save(dest) is True
|
||||
assert dest.read_bytes() == FAKE_PNG
|
||||
|
||||
def test_falls_back_to_filedrop_image(self, tmp_path):
|
||||
dest = tmp_path / "out.png"
|
||||
b64_png = base64.b64encode(FAKE_PNG).decode()
|
||||
with patch("hermes_cli.clipboard._get_ps_exe", return_value="powershell"):
|
||||
with patch("hermes_cli.clipboard.subprocess.run") as mock_run:
|
||||
mock_run.side_effect = [
|
||||
MagicMock(stdout="", returncode=1),
|
||||
MagicMock(stdout="", returncode=1),
|
||||
MagicMock(stdout=b64_png + "\n", returncode=0),
|
||||
]
|
||||
assert _windows_save(dest) is True
|
||||
assert mock_run.call_count == 3
|
||||
assert dest.read_bytes() == FAKE_PNG
|
||||
|
||||
def test_no_image_returns_false(self, tmp_path):
|
||||
dest = tmp_path / "out.png"
|
||||
with patch("hermes_cli.clipboard._get_ps_exe", return_value="powershell"):
|
||||
|
||||
Reference in New Issue
Block a user