* refactor: re-architect tests to mirror the codebase
* Update tests.yml
* fix: add missing tool_error imports after registry refactor
* fix(tests): replace patch.dict with monkeypatch to prevent env var leaks under xdist
patch.dict(os.environ) can leak TERMINAL_ENV across xdist workers,
causing test_code_execution tests to hit the Modal remote path.
* fix(tests): fix update_check and telegram xdist failures
- test_update_check: replace patch("hermes_cli.banner.os.getenv") with
monkeypatch.setenv("HERMES_HOME") — banner.py no longer imports os
directly, it uses get_hermes_home() from hermes_constants.
- test_telegram_conflict/approval_buttons: provide real exception classes
for telegram.error mock (NetworkError, TimedOut, BadRequest) so the
except clause in connect() doesn't fail with "catching classes that do
not inherit from BaseException" when xdist pollutes sys.modules.
* fix(tests): accept unavailable_models kwarg in _prompt_model_selection mock
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
"""Regression tests for CLI /retry history replacement semantics."""
|
|
|
|
from tests.cli.test_cli_init import _make_cli
|
|
|
|
|
|
def test_retry_last_truncates_history_before_requeueing_message():
|
|
cli = _make_cli()
|
|
cli.conversation_history = [
|
|
{"role": "user", "content": "first"},
|
|
{"role": "assistant", "content": "one"},
|
|
{"role": "user", "content": "retry me"},
|
|
{"role": "assistant", "content": "old answer"},
|
|
]
|
|
|
|
retry_msg = cli.retry_last()
|
|
|
|
assert retry_msg == "retry me"
|
|
assert cli.conversation_history == [
|
|
{"role": "user", "content": "first"},
|
|
{"role": "assistant", "content": "one"},
|
|
]
|
|
|
|
cli.conversation_history.append({"role": "user", "content": retry_msg})
|
|
cli.conversation_history.append({"role": "assistant", "content": "new answer"})
|
|
|
|
assert [m["content"] for m in cli.conversation_history if m["role"] == "user"] == [
|
|
"first",
|
|
"retry me",
|
|
]
|
|
|
|
|
|
def test_process_command_retry_requeues_original_message_not_retry_command():
|
|
cli = _make_cli()
|
|
queued = []
|
|
|
|
class _Queue:
|
|
def put(self, value):
|
|
queued.append(value)
|
|
|
|
cli._pending_input = _Queue()
|
|
cli.conversation_history = [
|
|
{"role": "user", "content": "retry me"},
|
|
{"role": "assistant", "content": "old answer"},
|
|
]
|
|
|
|
cli.process_command("/retry")
|
|
|
|
assert queued == ["retry me"]
|
|
assert cli.conversation_history == []
|