Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added call connection id for recording and live and unit tests code. #38988

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -799,14 +799,14 @@ def start_recording(
) -> RecordingProperties:
# pylint:disable=protected-access
channel_affinity: List["ChannelAffinity"] = kwargs.pop("channel_affinity", None) or []
channel_affinity_internal = [c._to_generated() for c in channel_affinity]
channel_affinity_internal = [c._to_generated() for c in channel_affinity]
call_locator = build_call_locator(
kwargs.pop("call_locator", None),
kwargs.pop("server_call_id", None),
kwargs.pop("group_call_id", None),
kwargs.pop("room_id", None),
args
)
) if args else None
external_storage = build_external_storage(kwargs.pop("recording_storage", None))
call_connection_id = kwargs.pop("call_connection_id", None)
start_recording_request = StartCallRecordingRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

class TestCallRecordingClient(unittest.TestCase):
recording_id = "123"
call_connection_id = "10000000-0000-0000-0000-000000000000"

def test_start_recording(self):
def mock_send(_, **kwargs):
Expand Down Expand Up @@ -95,3 +96,17 @@ def mock_send(_, **kwargs):
"https://endpoint", AzureKeyCredential("fakeCredential=="), transport=Mock(send=mock_send)
)
callautomation_client.get_recording_properties(recording_id=self.recording_id)

def test_start_recording_with_call_connection_id(self):
def mock_send(_, **kwargs):
kwargs.pop("stream", None)
if kwargs:
raise ValueError(f"Received unexpected kwargs in transport: {kwargs}")
return mock_response(status_code=200, json_payload={"recording_id": "1", "recording_state": "2"})

callautomation_client = CallAutomationClient(
"https://endpoint", AzureKeyCredential("fakeCredential=="), transport=Mock(send=mock_send)
)
target_participant = CommunicationUserIdentifier("testId")
channel_affinity = ChannelAffinity(target_participant=target_participant, channel=0)
callautomation_client.start_recording(call_connection_id=self.call_connection_id, channel_affinity=[channel_affinity])
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

from callautomation_test_case import CallAutomationRecordedTestCase
from azure.communication.callautomation._shared.models import identifier_from_raw_id

from azure.communication.callautomation import (
CommunicationUserIdentifier,
ChannelAffinity
)

class TestCallAutomationClientAutomatedLiveTest(CallAutomationRecordedTestCase):

Expand Down Expand Up @@ -110,3 +113,41 @@ def test_create_VOIP_call_and_connect_call_then_hangup(self):

self.terminate_call(unique_id)
return

@recorded_by_proxy
def test_play_multiple_file_sources_with_operationcallbackurl_with_play_media_all(self):
# try to establish the call
caller = self.identity_client.create_user()
target = self.identity_client.create_user()
unique_id, call_connection, _, call_automation_client, callback_url = self.establish_callconnection_voip_connect_call(caller, target)

# check returned events
connected_event = self.check_for_event('CallConnected', call_connection._call_connection_id, timedelta(seconds=15))
participant_updated_event = self.check_for_event('ParticipantsUpdated', call_connection._call_connection_id, timedelta(seconds=15))

if connected_event is None:
raise ValueError("Caller CallConnected event is None")
if participant_updated_event is None:
raise ValueError("Caller ParticipantsUpdated event is None")

call_connection_properties = call_connection.get_call_properties()
call_connection_id = call_connection_properties.call_connection_id
target_participant = CommunicationUserIdentifier("testId")
channel_affinity = ChannelAffinity(target_participant=target_participant, channel=0)

# start recording request with call connection id.
start_recording = call_automation_client.start_recording(call_connection_id=call_connection_id, channel_affinity=[channel_affinity]
)
time.sleep(3)

# check for RecordingStateChanged event
recording_state_changed_event = self.check_for_event('RecordingStateChanged', call_connection._call_connection_id, timedelta(seconds=30))
if recording_state_changed_event is None:
raise ValueError("RecordingStateChanged event is None")

# stop recording request.
call_automation_client.stop_recording(recording_id=start_recording.recording_id)
time.sleep(3)

self.terminate_call(unique_id)
return
Loading