|
14 | 14 | from tests.mock_vws.utils import ( |
15 | 15 | add_target_to_vws, |
16 | 16 | get_vws_target, |
| 17 | + query, |
17 | 18 | target_summary, |
18 | 19 | wait_for_target_processed, |
19 | 20 | ) |
@@ -195,9 +196,49 @@ class TestRecognitionCounts: |
195 | 196 | Tests for the recognition counts in the summary. |
196 | 197 | """ |
197 | 198 |
|
198 | | - def test_recognition(self) -> None: |
| 199 | + def test_recognition( |
| 200 | + self, |
| 201 | + vuforia_database_keys: VuforiaDatabaseKeys, |
| 202 | + high_quality_image: io.BytesIO, |
| 203 | + ) -> None: |
199 | 204 | """ |
200 | | - See https://github.com/adamtheturtle/vws-python/issues/357 for |
201 | | - implementing this. |
| 205 | + The recognition counts stay at 0 even after recognitions. |
202 | 206 | """ |
203 | | - pass |
| 207 | + image_content = high_quality_image.getvalue() |
| 208 | + image_data_encoded = base64.b64encode(image_content).decode('ascii') |
| 209 | + |
| 210 | + target_response = add_target_to_vws( |
| 211 | + vuforia_database_keys=vuforia_database_keys, |
| 212 | + data={ |
| 213 | + 'name': 'example', |
| 214 | + 'width': 1, |
| 215 | + 'image': image_data_encoded, |
| 216 | + }, |
| 217 | + ) |
| 218 | + |
| 219 | + target_id = target_response.json()['target_id'] |
| 220 | + |
| 221 | + wait_for_target_processed( |
| 222 | + vuforia_database_keys=vuforia_database_keys, |
| 223 | + target_id=target_id, |
| 224 | + ) |
| 225 | + |
| 226 | + body = {'image': ('image.jpeg', image_content, 'image/jpeg')} |
| 227 | + |
| 228 | + query_response = query( |
| 229 | + vuforia_database_keys=vuforia_database_keys, |
| 230 | + body=body, |
| 231 | + ) |
| 232 | + |
| 233 | + [result] = query_response.json()['results'] |
| 234 | + assert result['target_id'] == target_id |
| 235 | + |
| 236 | + response = target_summary( |
| 237 | + vuforia_database_keys=vuforia_database_keys, |
| 238 | + target_id=target_id, |
| 239 | + ) |
| 240 | + |
| 241 | + assert response.json()['status'] == TargetStatuses.SUCCESS.value |
| 242 | + assert response.json()['total_recos'] == 0 |
| 243 | + assert response.json()['current_month_recos'] == 0 |
| 244 | + assert response.json()['previous_month_recos'] == 0 |
0 commit comments