Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devcycle_python_sdk/api/event_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def publish_events(self, batch: List[UserEventsBatchRecord]) -> str:
Attempts to send a batch of events to the server
"""
retries_remaining = self.max_batch_retries + 1
timeout = self.options.event_request_timeout_ms
timeout = self.options.event_request_timeout_ms / 1000.0

payload_json = json.dumps(
{
Expand Down
18 changes: 18 additions & 0 deletions test/api/test_event_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ def test_publish_events_empty_batch(self):
message = self.test_client.publish_events([])
self.assertEqual(message, "Successfully received 1 event batches.")

@responses.activate
def test_publish_events_timeout_in_seconds(self):
responses.add(responses.POST, self.test_batch_url, json={"message": "ok"})
self.test_client.publish_events(self.test_batch)
self.assertEqual(responses.calls[0].request.req_kwargs["timeout"], 10.0)

@responses.activate
def test_publish_events_custom_timeout_in_seconds(self):
client = EventAPIClient(
self.sdk_key,
DevCycleLocalOptions(
events_api_uri="http://localhost:8080", event_request_timeout_ms=250
),
)
responses.add(responses.POST, self.test_batch_url, json={"message": "ok"})
client.publish_events(self.test_batch)
self.assertEqual(responses.calls[0].request.req_kwargs["timeout"], 0.25)

@responses.activate(registry=OrderedRegistry)
def test_publish_events_retries_exceeded(self):
for i in range(2):
Expand Down
Loading