From 41f38bcc7d91cc50693e7113442d70456bab05b9 Mon Sep 17 00:00:00 2001 From: vocode-petern Date: Fri, 5 Jul 2024 10:23:27 -0700 Subject: [PATCH] Support passthrough of AsyncHTTPTransport (#603) Support passthrough of AsyncHTTPTransport object --- tests/streaming/action/test_external_actions_requester.py | 2 ++ vocode/streaming/action/external_actions_requester.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/streaming/action/test_external_actions_requester.py b/tests/streaming/action/test_external_actions_requester.py index c9d2f8b35..626d5db93 100644 --- a/tests/streaming/action/test_external_actions_requester.py +++ b/tests/streaming/action/test_external_actions_requester.py @@ -5,6 +5,7 @@ import os from typing import Any, Callable, Dict +import httpx import pytest from httpx import Request, Response from pytest_httpx import HTTPXMock @@ -65,6 +66,7 @@ async def test_send_request_responses( JSON_SCHEMA, base64.b64encode(os.urandom(32)).decode(), additional_payload_values={"call_id": "call_id"}, + transport=httpx.AsyncHTTPTransport(retries=3, verify=True), ) assert response.success is expected_success diff --git a/vocode/streaming/action/external_actions_requester.py b/vocode/streaming/action/external_actions_requester.py index ff82911bd..658192e7b 100644 --- a/vocode/streaming/action/external_actions_requester.py +++ b/vocode/streaming/action/external_actions_requester.py @@ -52,6 +52,7 @@ async def send_request( payload: Dict[str, Any], signature_secret: str, additional_payload_values: Dict[str, Any] = {}, + transport: httpx.AsyncHTTPTransport = httpx.AsyncHTTPTransport(retries=2), ) -> ExternalActionResponse: encoded_payload = json.dumps({"payload": payload} | additional_payload_values).encode( "utf-8" @@ -63,7 +64,6 @@ async def send_request( "x-vocode-signature": self._encode_payload(encoded_payload, signature_secret), } - transport = httpx.AsyncHTTPTransport(retries=2) async with httpx.AsyncClient( headers=headers, transport=transport,