44import pytest
55
66MOCK_IP_ADDRESS = "localhost"
7- MOCK_PORT = 5000
7+ MOCK_PORT = 80
88OBJ_URL = "http://{}:{}/v1/vision/detection" .format (MOCK_IP_ADDRESS , MOCK_PORT )
99SCENE_URL = "http://{}:{}/v1/vision/scene" .format (MOCK_IP_ADDRESS , MOCK_PORT )
1010FACE_DETECTION_URL = "http://{}:{}/v1/vision/face" .format (MOCK_IP_ADDRESS , MOCK_PORT )
1616MOCK_TIMEOUT = 8
1717
1818MOCK_SCENE_RESPONSE = {"success" : True , "label" : "street" , "confidence" : 0.86745402 }
19+ MOCK_SCENE_PREDICTION = {"label" : "street" , "confidence" : 0.86745402 }
1920
2021MOCK_OBJECT_DETECTION_RESPONSE = {
2122 "success" : True ,
8788}
8889
8990
90- MOCK_RECOGNISED_FACES = {"Idris Elba" : 75.0 }
91+ MOCK_RECOGNIZED_FACES = {"Idris Elba" : 75.0 }
9192
9293
9394def test_DeepstackObject_detect ():
@@ -98,12 +99,12 @@ def test_DeepstackObject_detect():
9899 )
99100
100101 dsobject = ds .DeepstackObject (MOCK_IP_ADDRESS , MOCK_PORT )
101- dsobject .detect (MOCK_BYTES )
102- assert dsobject . predictions == MOCK_OBJECT_PREDICTIONS
102+ predictions = dsobject .detect (MOCK_BYTES )
103+ assert predictions == MOCK_OBJECT_PREDICTIONS
103104
104105
105106def test_DeepstackObject_detect_timeout ():
106- """Test a timeout. THIS SHOULD FAIL"""
107+ """Test a timeout. THIS SHOULD FAIL, CURRENTLY BROKEN TEST """
107108 with pytest .raises (ds .DeepstackException ) as excinfo :
108109 with requests_mock .Mocker () as mock_req :
109110 mock_req .post (OBJ_URL , exc = requests .exceptions .ConnectTimeout )
@@ -119,8 +120,8 @@ def test_DeepstackScene():
119120 mock_req .post (SCENE_URL , status_code = ds .HTTP_OK , json = MOCK_SCENE_RESPONSE )
120121
121122 dsscene = ds .DeepstackScene (MOCK_IP_ADDRESS , MOCK_PORT )
122- dsscene .detect (MOCK_BYTES )
123- assert dsscene . predictions == MOCK_SCENE_RESPONSE
123+ predictions = dsscene .recognize (MOCK_BYTES )
124+ assert predictions == MOCK_SCENE_PREDICTION
124125
125126
126127def test_DeepstackFace ():
@@ -133,8 +134,8 @@ def test_DeepstackFace():
133134 )
134135
135136 dsface = ds .DeepstackFace (MOCK_IP_ADDRESS , MOCK_PORT )
136- dsface .detect (MOCK_BYTES )
137- assert dsface . predictions == MOCK_FACE_DETECTION_RESPONSE ["predictions" ]
137+ predictions = dsface .detect (MOCK_BYTES )
138+ assert predictions == MOCK_FACE_DETECTION_RESPONSE ["predictions" ]
138139
139140
140141def test_get_objects ():
@@ -167,6 +168,6 @@ def test_get_confidences_above_threshold():
167168 )
168169
169170
170- def test_get_recognised_faces ():
171+ def test_get_recognized_faces ():
171172 predictions = MOCK_FACE_RECOGNITION_RESPONSE ["predictions" ]
172- assert ds .get_recognised_faces (predictions ) == MOCK_RECOGNISED_FACES
173+ assert ds .get_recognized_faces (predictions ) == MOCK_RECOGNIZED_FACES
0 commit comments