Skip to content

Commit 0e4516a

Browse files
Merge pull request #892 from adamtheturtle/custom-wait-between-requests
Custom wait between requests
2 parents 96f7eeb + 9f565ea commit 0e4516a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/test_vws.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,48 @@ 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_default_seconds_between_requests(
283+
self,
284+
high_quality_image: io.BytesIO,
285+
) -> None:
286+
"""
287+
By default, 0.2 seconds are waited between polling requests.
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+
)
296+
297+
target_id = client.add_target(
298+
name='x',
299+
width=1,
300+
image=high_quality_image,
301+
)
302+
303+
client.wait_for_target_processed(target_id=target_id)
304+
report = client.get_database_summary_report()
305+
expected_requests = (
306+
# Add target request
307+
1 +
308+
# Database summary request
309+
1 +
310+
# Initial request
311+
1 +
312+
# Request after 0.2 seconds - not processed
313+
1 +
314+
# Request after 0.4 seconds - not processed
315+
# This assumes that there is less than 0.1 seconds taken
316+
# between the start of the target processing and the start of
317+
# waiting for the target to be processed.
318+
1 +
319+
# Request after 0.6 seconds - processed
320+
1
321+
)
322+
assert report['request_usage'] == expected_requests
323+
282324

283325
class TestGetDuplicateTargets:
284326
"""

0 commit comments

Comments
 (0)