@@ -53,7 +53,7 @@ def _wait_for_image_numbers(
5353 ValueError: The numbers of images in various categories do not match
5454 within the time limit.
5555 """
56- requirements = {
56+ expected = {
5757 "active_images" : active_images ,
5858 "inactive_images" : inactive_images ,
5959 "failed_images" : failed_images ,
@@ -72,36 +72,38 @@ def _wait_for_image_numbers(
7272 # request quota.
7373 sleep_seconds = 0.2
7474
75- for key , value in requirements .items ():
76- while True :
77- seconds_waited = time .monotonic () - start_time
78- if seconds_waited > maximum_wait_seconds : # pragma: no cover
79- timeout_message = "Timed out waiting"
80- raise ValueError (timeout_message )
81-
82- report = vws_client .get_database_summary_report ()
83- key_to_relevant_images_in_summary = {
84- "active_images" : report .active_images ,
85- "inactive_images" : report .inactive_images ,
86- "failed_images" : report .failed_images ,
87- "processing_images" : report .processing_images ,
88- }
89- relevant_images_in_summary = key_to_relevant_images_in_summary [key ]
90- if value != relevant_images_in_summary : # pragma: no cover
91- message = (
92- f"Expected { value } `{ key } `s. "
93- f"Found { relevant_images_in_summary } `{ key } `s. "
94- f"We have waited { int (seconds_waited )} second(s)."
95- )
96- LOGGER .debug (msg = message )
97-
98- time .sleep (sleep_seconds )
99-
100- # This makes the entire test invalid.
101- # However, we have found that without this Vuforia is flaky.
102- # We have waited over 10 minutes for the summary to change and
103- # that is not sustainable in a test suite.
104- break
75+ while True :
76+ seconds_waited = time .monotonic () - start_time
77+ if seconds_waited > maximum_wait_seconds : # pragma: no cover
78+ timeout_message = "Timed out waiting"
79+ raise ValueError (timeout_message )
80+
81+ database_summary_report = vws_client .get_database_summary_report ()
82+ actual = {
83+ "active_images" : database_summary_report .active_images ,
84+ "inactive_images" : database_summary_report .inactive_images ,
85+ "failed_images" : database_summary_report .failed_images ,
86+ "processing_images" : database_summary_report .processing_images ,
87+ }
88+ if actual == expected :
89+ return
90+
91+ message = (
92+ f"Expected { expected } . "
93+ f"Found { actual } . "
94+ f"We have waited { int (seconds_waited )} second(s)."
95+ )
96+ LOGGER .debug (msg = message )
97+
98+ time .sleep (sleep_seconds )
99+
100+ # This break makes the entire test invalid.
101+ # However, we have found that without this Vuforia is flaky.
102+ # We have waited over 10 minutes for the summary to change and
103+ # that is not sustainable in a test suite.
104+ # That might be because we think some images will go into a particular
105+ # state but they don't.
106+ break
105107
106108
107109@pytest .mark .usefixtures ("verify_mock_vuforia" )
0 commit comments