4
4
import pytest
5
5
6
6
MOCK_IP_ADDRESS = "localhost"
7
- MOCK_PORT = 5000
7
+ MOCK_PORT = 80
8
8
OBJ_URL = "http://{}:{}/v1/vision/detection" .format (MOCK_IP_ADDRESS , MOCK_PORT )
9
9
SCENE_URL = "http://{}:{}/v1/vision/scene" .format (MOCK_IP_ADDRESS , MOCK_PORT )
10
10
FACE_DETECTION_URL = "http://{}:{}/v1/vision/face" .format (MOCK_IP_ADDRESS , MOCK_PORT )
16
16
MOCK_TIMEOUT = 8
17
17
18
18
MOCK_SCENE_RESPONSE = {"success" : True , "label" : "street" , "confidence" : 0.86745402 }
19
+ MOCK_SCENE_PREDICTION = {"label" : "street" , "confidence" : 0.86745402 }
19
20
20
21
MOCK_OBJECT_DETECTION_RESPONSE = {
21
22
"success" : True ,
87
88
}
88
89
89
90
90
- MOCK_RECOGNISED_FACES = {"Idris Elba" : 75.0 }
91
+ MOCK_RECOGNIZED_FACES = {"Idris Elba" : 75.0 }
91
92
92
93
93
94
def test_DeepstackObject_detect ():
@@ -98,12 +99,12 @@ def test_DeepstackObject_detect():
98
99
)
99
100
100
101
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
103
104
104
105
105
106
def test_DeepstackObject_detect_timeout ():
106
- """Test a timeout. THIS SHOULD FAIL"""
107
+ """Test a timeout. THIS SHOULD FAIL, CURRENTLY BROKEN TEST """
107
108
with pytest .raises (ds .DeepstackException ) as excinfo :
108
109
with requests_mock .Mocker () as mock_req :
109
110
mock_req .post (OBJ_URL , exc = requests .exceptions .ConnectTimeout )
@@ -119,8 +120,8 @@ def test_DeepstackScene():
119
120
mock_req .post (SCENE_URL , status_code = ds .HTTP_OK , json = MOCK_SCENE_RESPONSE )
120
121
121
122
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
124
125
125
126
126
127
def test_DeepstackFace ():
@@ -133,8 +134,8 @@ def test_DeepstackFace():
133
134
)
134
135
135
136
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" ]
138
139
139
140
140
141
def test_get_objects ():
@@ -167,6 +168,6 @@ def test_get_confidences_above_threshold():
167
168
)
168
169
169
170
170
- def test_get_recognised_faces ():
171
+ def test_get_recognized_faces ():
171
172
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