b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
"""Tests for browser_camofox._get_command_timeout — config-driven timeout."""
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
class TestCamofoxCommandTimeout:
|
|
"""Verify that the Camofox HTTP backend reads browser.command_timeout."""
|
|
|
|
def test_default_is_30(self):
|
|
"""When config has no browser.command_timeout, default to 30s."""
|
|
from tools.browser_camofox import _get_command_timeout
|
|
|
|
# Clear cache
|
|
import tools.browser_camofox as mod
|
|
mod._cmd_timeout_resolved = False
|
|
mod._cached_cmd_timeout = None
|
|
|
|
with patch("tools.browser_camofox.read_raw_config", return_value={}):
|
|
assert _get_command_timeout() == 30
|
|
|
|
def test_reads_from_config(self):
|
|
"""Read browser.command_timeout from config.yaml."""
|
|
from tools.browser_camofox import _get_command_timeout
|
|
|
|
import tools.browser_camofox as mod
|
|
mod._cmd_timeout_resolved = False
|
|
mod._cached_cmd_timeout = None
|
|
|
|
cfg = {"browser": {"command_timeout": 90}}
|
|
with patch("tools.browser_camofox.read_raw_config", return_value=cfg):
|
|
assert _get_command_timeout() == 90
|
|
|
|
def test_floor_at_5s(self):
|
|
"""Config values below 5 are clamped to 5."""
|
|
from tools.browser_camofox import _get_command_timeout
|
|
|
|
import tools.browser_camofox as mod
|
|
mod._cmd_timeout_resolved = False
|
|
mod._cached_cmd_timeout = None
|
|
|
|
cfg = {"browser": {"command_timeout": 1}}
|
|
with patch("tools.browser_camofox.read_raw_config", return_value=cfg):
|
|
assert _get_command_timeout() == 5
|
|
|
|
def test_cached_after_first_call(self):
|
|
"""Config is read only once; subsequent calls use cached value."""
|
|
from tools.browser_camofox import _get_command_timeout
|
|
|
|
import tools.browser_camofox as mod
|
|
mod._cmd_timeout_resolved = False
|
|
mod._cached_cmd_timeout = None
|
|
|
|
mock_read = MagicMock(return_value={"browser": {"command_timeout": 45}})
|
|
with patch("tools.browser_camofox.read_raw_config", mock_read):
|
|
_get_command_timeout()
|
|
_get_command_timeout()
|
|
mock_read.assert_called_once()
|
|
|
|
def test_config_read_error_falls_back(self):
|
|
"""If config read raises, fall back to 30s."""
|
|
from tools.browser_camofox import _get_command_timeout
|
|
|
|
import tools.browser_camofox as mod
|
|
mod._cmd_timeout_resolved = False
|
|
mod._cached_cmd_timeout = None
|
|
|
|
with patch("tools.browser_camofox.read_raw_config", side_effect=Exception("no config")):
|
|
assert _get_command_timeout() == 30
|