Skip to content

Commit 95ddc39

Browse files
committed
fix: missing coverage
1 parent df51dbc commit 95ddc39

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
- Reduced polling when checking for job completion.
1212
- Removed print statements for endpoint calls.
13+
- Serverless progress updates no longer restricted to only strings.
14+
15+
## Changed
16+
17+
- Removed `pillow` dependency.
18+
- Removed `python-dotenv` dependency.
19+
- Removed `setuptools_scm` from required dependencies.
1320

1421
---
1522

tests/test_endpoint/test_runner.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'''
44

55
import unittest
6-
from unittest import mock
76
from unittest.mock import patch, Mock
87
import requests
98

@@ -194,6 +193,23 @@ def test_run_sync(self, mock_client_request):
194193

195194
self.assertEqual(run_request, {"result": "YOUR_MODEL_OUTPUT_VALUE"})
196195

196+
@patch.object(runpod.endpoint.runner.RunPodClient, '_request')
197+
def test_run_sync_with_timeout(self, mock_client_request):
198+
'''
199+
Tests Endpoint.run_sync with timeout
200+
'''
201+
mock_client_request.return_value = {
202+
"id": "123",
203+
"status": "IN_PROGRESS"
204+
}
205+
206+
runpod.api_key = "MOCK_API_KEY"
207+
endpoint = runpod.Endpoint("ENDPOINT_ID")
208+
209+
request_data = {"YOUR_MODEL_INPUT_JSON": "YOUR_MODEL_INPUT_VALUE"}
210+
with self.assertRaises(TimeoutError):
211+
endpoint.run_sync(request_data, timeout=1)
212+
197213

198214
class TestJob(unittest.TestCase):
199215
''' Tests for Job '''
@@ -245,6 +261,19 @@ def test_output_with_sleep(self, mock_client):
245261

246262
self.assertEqual(output, "Job output")
247263

264+
@patch('runpod.endpoint.runner.RunPodClient')
265+
def test_output_timeout(self, mock_client):
266+
'''
267+
Tests Job.output with timeout
268+
'''
269+
mock_client.get.return_value = {
270+
"status": "IN_PROGRESS"
271+
}
272+
273+
job = runner.Job("endpoint_id", "job_id", mock_client)
274+
with self.assertRaises(TimeoutError):
275+
job.output(timeout=1)
276+
248277
@patch('runpod.endpoint.runner.RunPodClient')
249278
def test_job_status(self, mock_client):
250279
'''
@@ -262,3 +291,4 @@ def test_job_status(self, mock_client):
262291
job = runner.Job("endpoint_id", "job_id", mock_client)
263292
self.assertEqual(job.status(), "IN_PROGRESS")
264293
self.assertEqual(job.status(), "COMPLETED")
294+
self.assertEqual(job.status(), "COMPLETED")

0 commit comments

Comments
 (0)