Skip to content

Commit 5999a21

Browse files
committed
Update test
1 parent 938f06f commit 5999a21

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/test_deepstack.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Placeholder
22

33
import deepstack.core as ds
4+
import requests
45
import requests_mock
6+
import pytest
57

68
MOCK_IP_ADDRESS = "localhost"
79
MOCK_PORT = 5000
@@ -46,7 +48,8 @@
4648
CONFIDENCE_THRESHOLD = 0.7
4749

4850

49-
def test_DeepstackObject():
51+
def test_DeepstackObject_process_image_bytes():
52+
"""Test a good response from server."""
5053
with requests_mock.Mocker() as mock_req:
5154
mock_req.post(MOCK_URL, status_code=ds.HTTP_OK, json=MOCK_RESPONSE)
5255

@@ -55,6 +58,17 @@ def test_DeepstackObject():
5558
assert dsobject.predictions == MOCK_PREDICTIONS
5659

5760

61+
def test_DeepstackObject_process_image_bytes_timeout():
62+
"""Test a timeout. THIS SHOULD FAIL"""
63+
with pytest.raises(ds.DeepstackException) as excinfo:
64+
with requests_mock.Mocker() as mock_req:
65+
mock_req.post(MOCK_URL, exc=requests.exceptions.ConnectTimeout)
66+
dsobject = ds.DeepstackObject(MOCK_IP_ADDRESS, MOCK_PORT)
67+
dsobject.process_image_bytes(MOCK_BYTES)
68+
assert False
69+
assert "SHOULD FAIL" in str(excinfo.value)
70+
71+
5872
def test_get_object_labels():
5973
"""Cant always be sure order of returned list items."""
6074
object_labels = ds.get_object_labels(MOCK_PREDICTIONS)

0 commit comments

Comments
 (0)