Skip to content

Commit c7cc87a

Browse files
Copilotjverce
andcommitted
Add timeout parameter support to Pipedream and AsyncPipedream constructors
Co-authored-by: jverce <[email protected]>
1 parent 5c827ba commit c7cc87a

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/pipedream/pipedream.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(
2828
),
2929
environment: PipedreamEnvironment = PipedreamEnvironment.PROD,
3030
workflow_domain: Optional[str] = None,
31+
timeout: Optional[float] = None,
3132
):
3233
if not project_id:
3334
raise ValueError("Project ID is required")
@@ -38,6 +39,7 @@ def __init__(
3839
project_environment=project_environment,
3940
project_id=project_id,
4041
token=(lambda: access_token),
42+
timeout=timeout,
4143
)
4244
else:
4345
super().__init__(
@@ -46,6 +48,7 @@ def __init__(
4648
project_id=project_id,
4749
client_id=client_id,
4850
client_secret=client_secret,
51+
timeout=timeout,
4952
)
5053

5154
if not workflow_domain:
@@ -79,6 +82,7 @@ def __init__(
7982
),
8083
environment: PipedreamEnvironment = PipedreamEnvironment.PROD,
8184
workflow_domain: Optional[str] = None,
85+
timeout: Optional[float] = None,
8286
):
8387
if not project_id:
8488
raise ValueError("Project ID is required")
@@ -89,6 +93,7 @@ def __init__(
8993
project_environment=project_environment,
9094
project_id=project_id,
9195
token=(lambda: access_token),
96+
timeout=timeout,
9297
)
9398
else:
9499
super().__init__(
@@ -97,6 +102,7 @@ def __init__(
97102
project_id=project_id,
98103
client_id=client_id,
99104
client_secret=client_secret,
105+
timeout=timeout,
100106
)
101107

102108
if not workflow_domain:

tests/custom/test_client.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,69 @@
11
import pytest
22

3+
from pipedream import AsyncPipedream, Pipedream
4+
35

46
# Get started with writing tests with pytest at https://docs.pytest.org
57
@pytest.mark.skip(reason="Unimplemented")
68
def test_client() -> None:
79
assert True
10+
11+
12+
def test_pipedream_accepts_timeout_with_access_token() -> None:
13+
"""Test that Pipedream accepts the timeout parameter with access_token."""
14+
client = Pipedream(
15+
project_id="test-project-id",
16+
access_token="test-token",
17+
timeout=5.0,
18+
)
19+
assert client._client_wrapper._timeout == 5.0
20+
21+
22+
def test_pipedream_accepts_timeout_with_client_credentials() -> None:
23+
"""Test that Pipedream accepts the timeout parameter with client credentials."""
24+
client = Pipedream(
25+
project_id="test-project-id",
26+
client_id="test-client-id",
27+
client_secret="test-client-secret",
28+
timeout=10.0,
29+
)
30+
assert client._client_wrapper._timeout == 10.0
31+
32+
33+
def test_async_pipedream_accepts_timeout_with_access_token() -> None:
34+
"""Test that AsyncPipedream accepts the timeout parameter with access_token."""
35+
client = AsyncPipedream(
36+
project_id="test-project-id",
37+
access_token="test-token",
38+
timeout=5.0,
39+
)
40+
assert client._client_wrapper._timeout == 5.0
41+
42+
43+
def test_async_pipedream_accepts_timeout_with_client_credentials() -> None:
44+
"""Test that AsyncPipedream accepts the timeout parameter with client credentials."""
45+
client = AsyncPipedream(
46+
project_id="test-project-id",
47+
client_id="test-client-id",
48+
client_secret="test-client-secret",
49+
timeout=15.0,
50+
)
51+
assert client._client_wrapper._timeout == 15.0
52+
53+
54+
def test_pipedream_default_timeout() -> None:
55+
"""Test that Pipedream uses the default timeout of 60 seconds when not specified."""
56+
client = Pipedream(
57+
project_id="test-project-id",
58+
access_token="test-token",
59+
)
60+
assert client._client_wrapper._timeout == 60
61+
62+
63+
def test_async_pipedream_default_timeout() -> None:
64+
"""Test that AsyncPipedream uses the default timeout of 60 seconds when not specified."""
65+
client = AsyncPipedream(
66+
project_id="test-project-id",
67+
access_token="test-token",
68+
)
69+
assert client._client_wrapper._timeout == 60

0 commit comments

Comments
 (0)