fix(tools): remove unnecessary crontab requirement from cronjob tool (#1638)
* fix(tools): remove unnecessary crontab requirement from cronjob tool
The hermes cron system is internal — it uses a JSON-based scheduler
ticked by the gateway (cron/scheduler.py), not system crontab.
The check for shutil.which('crontab') was preventing the cronjob tool
from being available in environments without crontab installed (e.g.
minimal Ubuntu containers).
Changes:
- Remove shutil.which('crontab') check from check_cronjob_requirements()
- Remove unused shutil import
- Update docstring to clarify internal scheduler is used
- Update tests to reflect new behavior and add coverage for all
session modes (interactive, gateway, exec_ask)
Fixes #1589
* test: add HERMES_EXEC_ASK coverage for cronjob requirements
Adds missing test for the exec_ask session mode, complementing
the cherry-picked fix from PR #1633.
---------
Co-authored-by: Bartok9 <bartokmagic@proton.me>
This commit is contained in:
parent
4b96d10bc3
commit
949fac192f
2 changed files with 30 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue