diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fa257c3..b3dd423 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -5,8 +5,6 @@ on: branches: - main pull_request: - branches: - - main jobs: test: diff --git a/src/fessctl/commands/theme.py b/src/fessctl/commands/theme.py index 25831a6..1a700bc 100644 --- a/src/fessctl/commands/theme.py +++ b/src/fessctl/commands/theme.py @@ -9,6 +9,10 @@ theme_app = typer.Typer() +# Fess fetches the theme list and the theme archive from a remote repository +# while serving these requests, which can take longer than the default timeout. +REMOTE_TIMEOUT = 60.0 + @theme_app.command("available") def available_themes( @@ -19,7 +23,7 @@ def available_themes( """ List the themes that can be installed (requires Fess 15.9+). """ - client = FessAPIClient(Settings()) + client = FessAPIClient(Settings(), timeout=REMOTE_TIMEOUT) result = client.get_available_themes() status = result.get("response", {}).get("status", 1) @@ -54,7 +58,7 @@ def install_theme( """ Install a theme by name and version (requires Fess 15.9+). """ - client = FessAPIClient(Settings()) + client = FessAPIClient(Settings(), timeout=REMOTE_TIMEOUT) result = client.install_theme(name, version) status = result.get("response", {}).get("status", 1) diff --git a/tests/unit/test_theme.py b/tests/unit/test_theme.py index 7d61c5d..427f5b8 100644 --- a/tests/unit/test_theme.py +++ b/tests/unit/test_theme.py @@ -63,3 +63,17 @@ def test_install_failure_exits_with_status(self, mock_client_class, runner): assert result.exit_code == 1 assert "HTTP 404" in result.stdout + + +class TestThemeTimeout: + @pytest.mark.parametrize("args", [["available"], ["install", "filesearch", "15.9.4"]]) + @patch("fessctl.commands.theme.FessAPIClient") + def test_remote_calls_use_a_long_timeout(self, mock_client_class, runner, args): + mock_client = Mock() + mock_client.get_available_themes.return_value = {"response": {"status": 0, "themes": []}} + mock_client.install_theme.return_value = {"response": {"status": 0}} + mock_client_class.return_value = mock_client + + runner.invoke(theme_app, args) + + assert mock_client_class.call_args.kwargs["timeout"] >= 60