|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | import base64 |
| 6 | +import datetime |
6 | 7 | import io |
7 | 8 | import random |
8 | 9 | import uuid |
9 | 10 | from typing import Optional |
10 | 11 |
|
11 | 12 | import pytest |
| 13 | +from freezegun import freeze_time |
12 | 14 | from mock_vws import MockVWS |
13 | 15 | from mock_vws.database import VuforiaDatabase |
14 | 16 |
|
15 | 17 | from vws import VWS, CloudRecoService |
16 | 18 | from vws.exceptions import TargetProcessingTimeout |
17 | | -from vws.reports import DatabaseSummaryReport |
| 19 | +from vws.reports import ( |
| 20 | + DatabaseSummaryReport, |
| 21 | + TargetStatuses, |
| 22 | + TargetSummaryReport, |
| 23 | +) |
18 | 24 |
|
19 | 25 |
|
20 | 26 | class TestAddTarget: |
@@ -184,29 +190,31 @@ def test_get_target_summary_report( |
184 | 190 | """ |
185 | 191 | Details of a target are returned by ``get_target_summary_report``. |
186 | 192 | """ |
187 | | - target_id = vws_client.add_target( |
188 | | - name='x', |
189 | | - width=1, |
190 | | - image=high_quality_image, |
191 | | - active_flag=True, |
192 | | - application_metadata=None, |
193 | | - ) |
| 193 | + date = '2018-04-25' |
| 194 | + target_name = uuid.uuid4().hex |
| 195 | + with freeze_time(date): |
| 196 | + target_id = vws_client.add_target( |
| 197 | + name=target_name, |
| 198 | + width=1, |
| 199 | + image=high_quality_image, |
| 200 | + active_flag=True, |
| 201 | + application_metadata=None, |
| 202 | + ) |
194 | 203 |
|
195 | 204 | result = vws_client.get_target_summary_report(target_id=target_id) |
196 | | - expected_keys = { |
197 | | - 'status', |
198 | | - 'result_code', |
199 | | - 'transaction_id', |
200 | | - 'database_name', |
201 | | - 'target_name', |
202 | | - 'upload_date', |
203 | | - 'active_flag', |
204 | | - 'tracking_rating', |
205 | | - 'total_recos', |
206 | | - 'current_month_recos', |
207 | | - 'previous_month_recos', |
208 | | - } |
209 | | - assert set(result.keys()) == expected_keys |
| 205 | + |
| 206 | + expected_report = TargetSummaryReport( |
| 207 | + status=TargetStatuses.SUCCESS, |
| 208 | + database_name=result.database_name, |
| 209 | + target_name=target_name, |
| 210 | + upload_date=datetime.date(2018, 4, 25), |
| 211 | + active_flag=True, |
| 212 | + tracking_rating=result.tracking_rating, |
| 213 | + total_recos=0, |
| 214 | + current_month_recos=0, |
| 215 | + previous_month_recos=0 |
| 216 | + ) |
| 217 | + assert result == expected_report |
210 | 218 |
|
211 | 219 |
|
212 | 220 | class TestGetDatabaseSummaryReport: |
|
0 commit comments