Skip to content

Commit 64c4b1c

Browse files
committed
Add test
1 parent 0e4516a commit 64c4b1c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/test_vws.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,49 @@ def test_default_seconds_between_requests(
321321
)
322322
assert report['request_usage'] == expected_requests
323323

324+
def test_custom_seconds_between_requests(
325+
self,
326+
high_quality_image: io.BytesIO,
327+
) -> None:
328+
"""
329+
It is possible to customize the time waited between polling requests.
330+
"""
331+
with MockVWS(processing_time_seconds=0.5) as mock:
332+
database = VuforiaDatabase()
333+
mock.add_database(database=database)
334+
client = VWS(
335+
server_access_key=database.server_access_key.decode(),
336+
server_secret_key=database.server_secret_key.decode(),
337+
)
338+
339+
target_id = client.add_target(
340+
name='x',
341+
width=1,
342+
image=high_quality_image,
343+
)
344+
345+
client.wait_for_target_processed(
346+
target_id=target_id,
347+
seconds_between_requests=0.3,
348+
)
349+
report = client.get_database_summary_report()
350+
expected_requests = (
351+
# Add target request
352+
1 +
353+
# Database summary request
354+
1 +
355+
# Initial request
356+
1 +
357+
# Request after 0.3 seconds - not processed
358+
# This assumes that there is less than 0.2 seconds taken
359+
# between the start of the target processing and the start of
360+
# waiting for the target to be processed.
361+
1 +
362+
# Request after 0.6 seconds - processed
363+
1
364+
)
365+
assert report['request_usage'] == expected_requests
366+
324367

325368
class TestGetDuplicateTargets:
326369
"""

0 commit comments

Comments
 (0)