Skip to content

Commit aaf25bc

Browse files
committed
Start of test
1 parent 9bc8f7c commit aaf25bc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/test_vws.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,42 @@ def test_custom_seconds_between_requests(
364364
)
365365
assert report['request_usage'] == expected_requests
366366

367+
def test_custom_timeout(
368+
self,
369+
high_quality_image: io.BytesIO,
370+
) -> None:
371+
"""
372+
It is possible to set a maximum timeout.
373+
"""
374+
with MockVWS(processing_time_seconds=0.5) as mock:
375+
database = VuforiaDatabase()
376+
mock.add_database(database=database)
377+
client = VWS(
378+
server_access_key=database.server_access_key.decode(),
379+
server_secret_key=database.server_secret_key.decode(),
380+
)
381+
382+
target_id = client.add_target(
383+
name='x',
384+
width=1,
385+
image=high_quality_image,
386+
)
387+
388+
report = client.get_target_summary_report(target_id=target_id)
389+
assert report['status'] == 'processing'
390+
with pytest.raises(TimeoutError):
391+
client.wait_for_target_processed(
392+
target_id=target_id,
393+
timeout_seconds=0.1,
394+
)
395+
396+
client.wait_for_target_processed(
397+
target_id=target_id,
398+
timeout_seconds=0.4,
399+
)
400+
report = client.get_target_summary_report(target_id=target_id)
401+
assert report['status'] != 'processing'
402+
367403

368404
class TestGetDuplicateTargets:
369405
"""

0 commit comments

Comments
 (0)