fix(google-chat): repair setup prompt imports

This commit is contained in:
helix4u 2026-05-08 12:55:20 -06:00 committed by Teknium
parent d10d19ebb7
commit cacb984732
2 changed files with 59 additions and 5 deletions

View file

@ -2936,15 +2936,14 @@ def interactive_setup() -> None:
prompt for env vars, persist them to ``~/.hermes/.env`` so the next
gateway restart picks them up.
"""
from hermes_cli.config import (
get_env_value,
save_env_value,
prompt,
prompt_yes_no,
from hermes_cli.cli_output import (
print_info,
print_success,
print_warning,
prompt,
prompt_yes_no,
)
from hermes_cli.config import get_env_value, save_env_value
existing_sub = get_env_value("GOOGLE_CHAT_SUBSCRIPTION_NAME")
if existing_sub:

View file

@ -2359,6 +2359,61 @@ class TestADCFallback:
assert "google_chat_service_account_json" in msg
class TestGoogleChatInteractiveSetup:
def test_interactive_setup_uses_shared_cli_prompt_helpers(self, monkeypatch):
"""Google Chat setup should not import prompt helpers from config.py."""
from plugins.platforms.google_chat import adapter as gc_mod
saved: dict[str, str] = {}
answers = {
"GCP project ID (e.g. my-project)": "demo-project",
"Pub/Sub subscription (projects/<proj>/subscriptions/<sub>)": (
"projects/demo-project/subscriptions/hermes-chat"
),
"Path to Service Account JSON (or inline JSON)": "/tmp/sa.json",
"Allowed user emails (comma-separated)": "alice@example.com, bob@example.com",
"Home space for cron/notification delivery (e.g. spaces/AAAA, or empty)": (
"spaces/AAAA"
),
}
def fake_get_env_value(key):
return saved.get(key, "")
def fake_save_env_value(key, value):
saved[key] = value
def fake_prompt(question, default=None, password=False):
return answers.get(question, default or "")
monkeypatch.setattr("hermes_cli.config.get_env_value", fake_get_env_value)
monkeypatch.setattr("hermes_cli.config.save_env_value", fake_save_env_value)
monkeypatch.setattr("hermes_cli.cli_output.prompt", fake_prompt)
monkeypatch.setattr(
"hermes_cli.cli_output.prompt_yes_no", lambda *_a, **_kw: True
)
monkeypatch.setattr(
"hermes_cli.cli_output.print_info", lambda *_a, **_kw: None
)
monkeypatch.setattr(
"hermes_cli.cli_output.print_success", lambda *_a, **_kw: None
)
monkeypatch.setattr(
"hermes_cli.cli_output.print_warning", lambda *_a, **_kw: None
)
gc_mod.interactive_setup()
assert saved["GOOGLE_CHAT_PROJECT_ID"] == "demo-project"
assert (
saved["GOOGLE_CHAT_SUBSCRIPTION_NAME"]
== "projects/demo-project/subscriptions/hermes-chat"
)
assert saved["GOOGLE_CHAT_SERVICE_ACCOUNT_JSON"] == "/tmp/sa.json"
assert saved["GOOGLE_CHAT_ALLOWED_USERS"] == "alice@example.com,bob@example.com"
assert saved["GOOGLE_CHAT_HOME_CHANNEL"] == "spaces/AAAA"
# ===========================================================================
# Supervisor reconnect (backoff + fatal)
# ===========================================================================