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: Test mock support recording and realtime SSML

Clémence Lesnéa42d5b0c5d81
diff --git a/tests/conftest.py b/tests/conftest.py
index 839f4b5..107e909 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -18,7 +18,9 @@ from azure.cognitiveservices.speech.interop import _spx_handle
from azure.communication.callautomation import FileSource, SsmlSource, TextSource
from azure.communication.callautomation._generated.aio.operations import (
CallMediaOperations,
+ CallRecordingOperations,
)
+from azure.communication.callautomation._generated.models import RecordingStateResponse
from azure.communication.callautomation._models import TransferCallResult
from azure.communication.callautomation.aio import (
CallAutomationClient,
@@ -48,6 +50,18 @@ class CallMediaOperationsMock(CallMediaOperations):
pass
+class CallRecordingOperationsMock(CallRecordingOperations):
+ def __init__(self) -> None:
+ pass
+
+ async def start_recording(
+ self,
+ *args, # noqa: ARG002
+ **kwargs, # noqa: ARG002
+ ) -> RecordingStateResponse:
+ return RecordingStateResponse()
+
+
class CallConnectionClientMock(CallConnectionClient):
_call_connection_id: str = "dummy"
_call_media_client = CallMediaOperationsMock()
@@ -125,6 +139,7 @@ class CallConnectionClientMock(CallConnectionClient):
class CallAutomationClientMock(CallAutomationClient):
_call_client: CallConnectionClientMock
+ _call_recording_client = CallRecordingOperationsMock()
def __init__(
self,
@@ -152,13 +167,13 @@ class SpeechSynthesizerMock(SpeechSynthesizer):
def __init__(self, play_media_callback: Callable[[str], None]) -> None:
self._play_media_callback = play_media_callback
- def speak_text_async(
+ def speak_ssml_async(
self,
- text: str,
+ ssml: str,
*args, # noqa: ARG002
**kwargs, # noqa: ARG002
) -> ResultFuture:
- self._play_media_callback(text)
+ self._play_media_callback(ssml)
return ResultFuture(
async_handle=_spx_handle(0),
get_function=lambda _: _spx_handle(0),