33"""
44
55import base64
6+ import datetime
67import io
78import random
89import uuid
910from typing import Optional
1011
1112import pytest
13+ from freezegun import freeze_time
1214from mock_vws import MockVWS
1315from mock_vws .database import VuforiaDatabase
1416
1517from vws import VWS , CloudRecoService
1618from vws .exceptions import TargetProcessingTimeout
17- from vws .reports import DatabaseSummaryReport
19+ from vws .reports import (
20+ DatabaseSummaryReport ,
21+ TargetStatuses ,
22+ TargetSummaryReport ,
23+ )
1824
1925
2026class TestAddTarget :
@@ -184,29 +190,31 @@ def test_get_target_summary_report(
184190 """
185191 Details of a target are returned by ``get_target_summary_report``.
186192 """
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+ )
194203
195204 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
210218
211219
212220class TestGetDatabaseSummaryReport :
@@ -292,10 +300,10 @@ def test_wait_for_target_processed(
292300 application_metadata = None ,
293301 )
294302 report = vws_client .get_target_summary_report (target_id = target_id )
295- assert report [ ' status' ] == 'processing'
303+ assert report . status == TargetStatuses . PROCESSING
296304 vws_client .wait_for_target_processed (target_id = target_id )
297305 report = vws_client .get_target_summary_report (target_id = target_id )
298- assert report [ ' status' ] != 'processing'
306+ assert report . status != TargetStatuses . PROCESSING
299307
300308 def test_default_seconds_between_requests (
301309 self ,
@@ -416,7 +424,7 @@ def test_custom_timeout(
416424 )
417425
418426 report = vws_client .get_target_summary_report (target_id = target_id )
419- assert report [ ' status' ] == 'processing'
427+ assert report . status == TargetStatuses . PROCESSING
420428 with pytest .raises (TargetProcessingTimeout ):
421429 vws_client .wait_for_target_processed (
422430 target_id = target_id ,
@@ -428,7 +436,7 @@ def test_custom_timeout(
428436 timeout_seconds = 0.5 ,
429437 )
430438 report = vws_client .get_target_summary_report (target_id = target_id )
431- assert report [ ' status' ] != 'processing'
439+ assert report . status != TargetStatuses . PROCESSING
432440
433441
434442class TestGetDuplicateTargets :
0 commit comments