File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Placeholder
2
2
3
3
import deepstack .core as ds
4
+ import requests
4
5
import requests_mock
6
+ import pytest
5
7
6
8
MOCK_IP_ADDRESS = "localhost"
7
9
MOCK_PORT = 5000
46
48
CONFIDENCE_THRESHOLD = 0.7
47
49
48
50
49
- def test_DeepstackObject ():
51
+ def test_DeepstackObject_process_image_bytes ():
52
+ """Test a good response from server."""
50
53
with requests_mock .Mocker () as mock_req :
51
54
mock_req .post (MOCK_URL , status_code = ds .HTTP_OK , json = MOCK_RESPONSE )
52
55
@@ -55,6 +58,17 @@ def test_DeepstackObject():
55
58
assert dsobject .predictions == MOCK_PREDICTIONS
56
59
57
60
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
+
58
72
def test_get_object_labels ():
59
73
"""Cant always be sure order of returned list items."""
60
74
object_labels = ds .get_object_labels (MOCK_PREDICTIONS )
You can’t perform that action at this time.
0 commit comments