diff --git a/tests/tools/test_cronjob_tools.py b/tests/tools/test_cronjob_tools.py index 2a9197083..d54b9066d 100644 --- a/tests/tools/test_cronjob_tools.py +++ b/tests/tools/test_cronjob_tools.py @@ -62,22 +62,44 @@ class TestScanCronPrompt: class TestCronjobRequirements: - def test_requires_crontab_binary_even_in_interactive_mode(self, monkeypatch): + def test_requires_no_crontab_binary(self, monkeypatch): + """Cron is internal (JSON-based scheduler), no system crontab needed.""" monkeypatch.setenv("HERMES_INTERACTIVE", "1") monkeypatch.delenv("HERMES_GATEWAY_SESSION", raising=False) monkeypatch.delenv("HERMES_EXEC_ASK", raising=False) - monkeypatch.setattr("shutil.which", lambda name: None) + # Even with no crontab in PATH, the cronjob tool should be available + # because hermes uses an internal scheduler, not system crontab. + assert check_cronjob_requirements() is True - assert check_cronjob_requirements() is False - - def test_accepts_interactive_mode_when_crontab_exists(self, monkeypatch): + def test_accepts_interactive_mode(self, monkeypatch): monkeypatch.setenv("HERMES_INTERACTIVE", "1") monkeypatch.delenv("HERMES_GATEWAY_SESSION", raising=False) monkeypatch.delenv("HERMES_EXEC_ASK", raising=False) - monkeypatch.setattr("shutil.which", lambda name: "/usr/bin/crontab") assert check_cronjob_requirements() is True + def test_accepts_gateway_session(self, monkeypatch): + monkeypatch.delenv("HERMES_INTERACTIVE", raising=False) + monkeypatch.setenv("HERMES_GATEWAY_SESSION", "1") + monkeypatch.delenv("HERMES_EXEC_ASK", raising=False) + + assert check_cronjob_requirements() is True + + def test_accepts_exec_ask(self, monkeypatch): + monkeypatch.delenv("HERMES_INTERACTIVE", raising=False) + monkeypatch.delenv("HERMES_GATEWAY_SESSION", raising=False) + monkeypatch.setenv("HERMES_EXEC_ASK", "1") + + assert check_cronjob_requirements() is True + + def test_rejects_when_no_session_env(self, monkeypatch): + """Without any session env vars, cronjob tool should not be available.""" + monkeypatch.delenv("HERMES_INTERACTIVE", raising=False) + monkeypatch.delenv("HERMES_GATEWAY_SESSION", raising=False) + monkeypatch.delenv("HERMES_EXEC_ASK", raising=False) + + assert check_cronjob_requirements() is False + # ========================================================================= # schedule_cronjob diff --git a/tools/cronjob_tools.py b/tools/cronjob_tools.py index 15971787b..c16e2ece9 100644 --- a/tools/cronjob_tools.py +++ b/tools/cronjob_tools.py @@ -8,7 +8,6 @@ Compatibility wrappers remain for direct Python callers and legacy tests. import json import os import re -import shutil import sys from pathlib import Path from typing import Any, Dict, List, Optional @@ -414,13 +413,10 @@ def check_cronjob_requirements() -> bool: """ Check if cronjob tools can be used. - Requires 'crontab' executable to be present in the system PATH. Available in interactive CLI mode and gateway/messaging platforms. + The cron system is internal (JSON file-based scheduler ticked by the gateway), + so no external crontab executable is required. """ - # Ensure the system can actually install and manage cron entries. - if not shutil.which("crontab"): - return False - return bool( os.getenv("HERMES_INTERACTIVE") or os.getenv("HERMES_GATEWAY_SESSION")