Skip to content

The agent that grows with you

test: trim timezone validation tests to two invariants; document the doctor check

teknium15f20bb8b63a3
diff --git a/tests/hermes_cli/test_config_validation.py b/tests/hermes_cli/test_config_validation.py
index 41321337d7b..5e52986d020 100644
--- a/tests/hermes_cli/test_config_validation.py
+++ b/tests/hermes_cli/test_config_validation.py
@@ -113,10 +113,6 @@ class TestVoiceSubmitModeValidation:
)
-def _tz_issues(config):
- return [i for i in validate_config_structure(config) if "timezone" in i.message]
-
-
def _has_tz_database() -> bool:
try:
import zoneinfo
@@ -126,43 +122,35 @@ def _has_tz_database() -> bool:
return False
+def _tz_issues(config):
+ return [i for i in validate_config_structure(config) if "timezone" in i.message]
+
+
class TestTimezoneValidation:
"""An invalid ``timezone`` silently puts the agent clock and every cron
schedule on server-local time (hermes_time._get_zoneinfo falls back with
- one log warning). validate_config_structure must report it."""
-
- def test_valid_zone_passes(self):
- assert _tz_issues({"timezone": "Asia/Tokyo", "model": {"provider": "nous"}}) == []
-
- def test_missing_or_blank_is_not_reported(self):
- assert _tz_issues({"model": {"provider": "nous"}}) == []
- assert _tz_issues({"timezone": "", "model": {"provider": "nous"}}) == []
- assert _tz_issues({"timezone": " ", "model": {"provider": "nous"}}) == []
- assert _tz_issues({"timezone": None, "model": {"provider": "nous"}}) == []
+ one log warning). validate_config_structure must report it (#111725)."""
@pytest.mark.skipif(not _has_tz_database(), reason="no tz database in this interpreter")
- def test_invalid_zone_is_reported(self):
+ def test_invalid_or_non_string_zone_is_an_error(self):
[issue] = _tz_issues({"timezone": "Asia/Tokio", "model": {"provider": "nous"}})
assert issue.severity == "error"
assert "Asia/Tokio" in issue.message
- assert "IANA" in issue.hint
- assert "HERMES_TIMEZONE" in issue.hint
-
- def test_non_string_is_reported(self):
+ assert "IANA" in issue.hint and "HERMES_TIMEZONE" in issue.hint
[issue] = _tz_issues({"timezone": 9, "model": {"provider": "nous"}})
- assert issue.severity == "error"
- assert "string" in issue.message
+ assert issue.severity == "error" and "string" in issue.message
- def test_silent_without_a_tz_database(self, monkeypatch):
- # Bare Windows without tzdata: ZoneInfo cannot load anything, including
- # UTC. A valid name must not be flagged just because it cannot be checked.
+ def test_valid_blank_missing_or_unverifiable_zone_is_silent(self, monkeypatch):
+ for cfg in ({"timezone": "Asia/Tokyo"}, {}, {"timezone": ""}, {"timezone": " "}, {"timezone": None}):
+ assert _tz_issues({**cfg, "model": {"provider": "nous"}}) == []
+ # Bare Windows without tzdata: ZoneInfo cannot load anything, including UTC.
+ # A name that cannot be checked must not be flagged.
import zoneinfo
def no_db(_key):
raise zoneinfo.ZoneInfoNotFoundError("no tz database")
monkeypatch.setattr(zoneinfo, "ZoneInfo", no_db)
- assert _tz_issues({"timezone": "Asia/Tokyo", "model": {"provider": "nous"}}) == []
assert _tz_issues({"timezone": "Asia/Tokio", "model": {"provider": "nous"}}) == []
diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.md
index 9d646606d4c..3e08cc9154d 100644
--- a/website/docs/user-guide/configuration.md
+++ b/website/docs/user-guide/configuration.md
@@ -2596,6 +2596,8 @@ timezone: "America/New_York" # IANA timezone (default: "" = server-local time)
Supported values: any IANA timezone identifier (e.g. `America/New_York`, `Europe/London`, `Asia/Kolkata`, `UTC`). Leave empty or omit for server-local time.
+`hermes doctor` (and the startup config check) reports a value the runtime cannot load — a typo such as `Asia/Tokio` would otherwise silently put the agent clock and every cron schedule on server-local time. `HERMES_TIMEZONE` overrides this key when set.
+
## Discord
Configure Discord-specific behavior for the messaging gateway: