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 11# Placeholder
22
33import deepstack .core as ds
4+ import requests
45import requests_mock
6+ import pytest
57
68MOCK_IP_ADDRESS = "localhost"
79MOCK_PORT = 5000
4648CONFIDENCE_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+
5872def test_get_object_labels ():
5973 """Cant always be sure order of returned list items."""
6074 object_labels = ds .get_object_labels (MOCK_PREDICTIONS )
You can’t perform that action at this time.
0 commit comments