From 67a9129debb1dc304fc29637586d28a56fcf69d7 Mon Sep 17 00:00:00 2001 From: Prabhu Teja Date: Thu, 14 Nov 2024 19:23:15 +0100 Subject: [PATCH] Add timeout to client task --- hide/toolkit/toolkit.py | 2 +- tests/test_hide_client.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hide/toolkit/toolkit.py b/hide/toolkit/toolkit.py index 6ef24dc..d4a2865 100644 --- a/hide/toolkit/toolkit.py +++ b/hide/toolkit/toolkit.py @@ -30,7 +30,7 @@ def run_task( """ try: result = self.client.run_task( - project_id=self.project.id, command=command, alias=alias + project_id=self.project.id, command=command, alias=alias, timeout=timeout ) return f"exit code: {result.exit_code}\nstdout: {result.stdout}\nstderr: {result.stderr}" except Exception as e: diff --git a/tests/test_hide_client.py b/tests/test_hide_client.py index ed5902a..9c1d1d6 100644 --- a/tests/test_hide_client.py +++ b/tests/test_hide_client.py @@ -146,6 +146,11 @@ def test_run_task_command_and_alias(client): client.run_task(PROJECT_ID, command="echo Hello", alias="build") +def test_run_task_negative_timeout(client): + with pytest.raises(HideClientError, match="Timeout must be a positive integer"): + client.run_task(PROJECT_ID, command="echo Hello", timeout=-1) + + def test_create_file_success(client): with patch("requests.post") as mock_post: mock_post.return_value = Mock(ok=True, json=lambda: FILE)