File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -201,3 +201,9 @@ def response(self) -> Response:
201201 The response returned by Vuforia which included this error.
202202 """
203203 return self ._response
204+
205+
206+ class TargetProcessingTimeout (Exception ):
207+ """
208+ Exception raised when waiting for a target to be processed times out.
209+ """
Original file line number Diff line number Diff line change @@ -279,6 +279,43 @@ def test_wait_for_target_processed(
279279 report = client .get_target_summary_report (target_id = target_id )
280280 assert report ['status' ] != 'processing'
281281
282+ def test_custom_timeout (
283+ self ,
284+ high_quality_image : io .BytesIO ,
285+ ) -> None :
286+ """
287+ It is possible to set a maximum timeout.
288+ """
289+ with MockVWS (processing_time_seconds = 0.5 ) as mock :
290+ database = VuforiaDatabase ()
291+ mock .add_database (database = database )
292+ client = VWS (
293+ server_access_key = database .server_access_key .decode (),
294+ server_secret_key = database .server_secret_key .decode (),
295+ base_vws_url = base_vws_url ,
296+ )
297+
298+ target_id = client .add_target (
299+ name = 'x' ,
300+ width = 1 ,
301+ image = high_quality_image ,
302+ )
303+
304+ report = client .get_target_summary_report (target_id = target_id )
305+ assert report ['status' ] == 'processing'
306+ with pytest .raises (TimeoutError ):
307+ client .wait_for_target_processed (
308+ target_id = target_id ,
309+ timeout_seconds = 0.1 ,
310+ )
311+
312+ client .wait_for_target_processed (
313+ target_id = target_id ,
314+ timeout_seconds = 0.4 ,
315+ )
316+ report = client .get_target_summary_report (target_id = target_id )
317+ assert report ['status' ] != 'processing'
318+
282319
283320class TestGetDuplicateTargets :
284321 """
You can’t perform that action at this time.
0 commit comments