File tree Expand file tree Collapse file tree 2 files changed +30
-13
lines changed
Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -532,13 +532,14 @@ def query(
532532 gmt = pytz .timezone ('GMT' )
533533 now = datetime .datetime .now (tz = gmt )
534534
535- minimum_time_since_delete = datetime .timedelta (seconds = 7 )
535+ # See https://github.com/adamtheturtle/vws-python/issues/623 for making
536+ # this customizable.
537+ minimum_time_since_delete = datetime .timedelta (seconds = 3 )
536538
537539 for target in self .mock_web_services_api .targets :
538- time_difference = now - target .delete_date
539540 delete_processing = bool (
540- target .delete_date and
541- time_difference < minimum_time_since_delete
541+ target .delete_date
542+ and ( now - target . delete_date ) < minimum_time_since_delete ,
542543 )
543544 if target .image .getvalue () == image :
544545 if target .status == TargetStatuses .PROCESSING .value :
Original file line number Diff line number Diff line change @@ -1431,17 +1431,33 @@ def test_deleted_and_wait(
14311431 target_id = target_id ,
14321432 )
14331433
1434- # TODO retry in a loop instead
1435- time .sleep (30 )
1436-
14371434 body = {'image' : ('image.jpeg' , image_content , 'image/jpeg' )}
14381435
1439- response = query (
1440- vuforia_database_keys = vuforia_database_keys ,
1441- body = body ,
1442- )
1436+ # In practice, we have seen a delay of up to 30 seconds between
1437+ # deleting a target and having no 500 errors.
1438+ #
1439+ # We wait up to 60 seconds to be safe.
1440+ total_waited = 0
1441+ while True :
1442+ response = query (
1443+ vuforia_database_keys = vuforia_database_keys ,
1444+ body = body ,
1445+ )
14431446
1444- assert_query_success (response = response )
1445- assert response .json ()['results' ] == []
1447+ try :
1448+ assert_query_success (response = response )
1449+ except AssertionError :
1450+ # The response text for a 500 response is not consistent.
1451+ # Therefore we only test for consistent features.
1452+ assert 'Error 500 Server Error' in response .text
1453+ assert 'HTTP ERROR 500' in response .text
1454+ assert 'Problem accessing /v1/query' in response .text
1455+ time .sleep (2 )
1456+ total_waited += 2
1457+ else :
1458+ assert response .json ()['results' ] == []
1459+ break
1460+
1461+ assert total_waited < 60
14461462
14471463 # TODO No sleep and inactive
You can’t perform that action at this time.
0 commit comments