Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: Catch LLM output during tests

Clémence Lesné7ca01bf5c6ba
diff --git a/tests/conftest.py b/tests/conftest.py
index a4defe2..77f32a3 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -48,10 +48,11 @@ class CallConnectionClientMock(CallConnectionClient):
async def start_recognizing_media(
self,
+ play_prompt: Union[FileSource, TextSource, SsmlSource],
*args,
**kwargs,
) -> None:
- pass
+ self._log_media(play_prompt)
async def play_media(
self,
@@ -59,13 +60,7 @@ class CallConnectionClientMock(CallConnectionClient):
*args,
**kwargs,
) -> None:
- if isinstance(play_source, TextSource):
- self._play_media_callback(play_source.text.strip())
- elif isinstance(play_source, SsmlSource):
- # deepcode ignore InsecureXmlParser/test: SSML is internally generated
- for text in ET.fromstring(play_source.ssml_text).itertext():
- if text.strip():
- self._play_media_callback(text.strip())
+ self._log_media(play_source)
async def transfer_call_to_participant(
self,
@@ -88,6 +83,17 @@ class CallConnectionClientMock(CallConnectionClient):
) -> None:
pass
+ def _log_media(
+ self, play_source: Union[FileSource, TextSource, SsmlSource]
+ ) -> None:
+ if isinstance(play_source, TextSource):
+ self._play_media_callback(play_source.text.strip())
+ elif isinstance(play_source, SsmlSource):
+ # deepcode ignore InsecureXmlParser/test: SSML is internally generated
+ for text in ET.fromstring(play_source.ssml_text).itertext():
+ if text.strip():
+ self._play_media_callback(text.strip())
+
class DeepEvalAzureOpenAI(GPTModel):
_cache: pytest.Cache