Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
Expand Down
8 changes: 6 additions & 2 deletions src/fessctl/commands/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading