mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 13:26:40 +00:00
browser.user_data_dir, chromium_args, cloud_provider and every other browser.* knob were read with
read_raw_config, which skips the managed overlay and ${VAR} expansion: a managed profile pin or
flag set was ignored, and ${HOME}/chrome-profile became a literal dir under HERMES_HOME. The session
layer's one reader (browser_session_cloud.browser_section) now uses load_user_config_effective, and
the other raw browser.* reads go through it or the same loader: browser_exec's cloud routing
(browser_use_cli._read_browser_cfg), the real-profile pin (browser_connect._browser_setting) and
/browser status's cdp_url (methods_browser, now browser_session_cdp.get_cdp_override_raw). Tests
that stubbed read_raw_config for browser.* now stub the effective loader.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
"""Regression tests for the browser command-timeout cache (#14331).
|
|
|
|
Before the fix the cache could be marked resolved while still holding ``None``, so a caller evaluating
|
|
``max(timeout, floor)`` crashed with ``TypeError``. ``browser_session_cloud.command_timeout`` (the floor
|
|
of the Chromium launch timeout) must answer an int even when the config read fails.
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from tools import browser_session_cloud
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _fresh_cache():
|
|
browser_session_cloud.reset_caches()
|
|
yield
|
|
browser_session_cloud.reset_caches()
|
|
|
|
|
|
class TestGetCommandTimeoutRace:
|
|
def test_returns_default_when_config_read_raises(self):
|
|
"""If config reading blows up, we still return an int (not None), and the memoised value is that int."""
|
|
with patch("hermes_cli.config_effective.load_user_config_effective", side_effect=OSError("boom")):
|
|
result = browser_session_cloud.command_timeout()
|
|
|
|
assert isinstance(result, int)
|
|
assert result == browser_session_cloud.DEFAULT_COMMAND_TIMEOUT
|
|
# The cached slot must hold the int, never None.
|
|
assert browser_session_cloud.command_timeout() == browser_session_cloud.DEFAULT_COMMAND_TIMEOUT
|