-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Summary
Add support for simulating slow HTTP responses to enable testing of request timeout handling in client code.
Proposed Interface
from mock_vws import MockVWS
# Simulate 0.5 second delay on all responses
with MockVWS(response_delay_seconds=0.5) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
# Client with short timeout will fail
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
request_timeout_seconds=0.1,
)
vws_client.list_targets() # Raises requests.exceptions.TimeoutUse Case
vws-python recently added configurable request_timeout_seconds to VWS and CloudRecoService. To properly test this, we need to verify that:
- Short timeouts raise
requests.exceptions.Timeoutwhen the server is slow - Longer timeouts allow slow responses to complete
Currently, we're using unittest.mock.patch to intercept requests.request and artificially raise Timeout, but this:
- Doesn't test the real timeout mechanism
- Requires ugly type annotation hacks
- Tests at the wrong layer
With response_delay_seconds, we could test the actual integration end-to-end.
Expected Behavior
response_delay_secondsdefaults to0(no delay)- When set, all mock responses are delayed by the specified number of seconds
- The delay happens at the HTTP response level so that
requests' native timeout handling triggers naturally
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels