Skip to content

Commit e354a95

Browse files
turalfturalf
andauthored
Fix python sms live test failures (Azure#16385)
* Fix sms client to adapt new phone number model * Fix async test Co-authored-by: turalf <tufarhad@microsoft.com>
1 parent db4ca2e commit e354a95

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

sdk/communication/azure-communication-sms/azure/communication/sms/_sms_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def send(self, from_phone_number, # type: ~azure.communication.sms.PhoneNumberId
9393
send_sms_options = kwargs.pop('send_sms_options', None)
9494

9595
request = SendMessageRequest(
96-
from_property=from_phone_number,
97-
to=to_phone_numbers,
96+
from_property=from_phone_number.phone_number,
97+
to=[p.phone_number for p in to_phone_numbers],
9898
message=message,
9999
send_sms_options=send_sms_options,
100100
**kwargs)

sdk/communication/azure-communication-sms/azure/communication/sms/aio/_sms_client_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(
4040
"invalid credential from connection string.")
4141

4242
self._endpoint = endpoint
43-
self._authentication_policy = get_authentication_policy(endpoint, credential)
43+
self._authentication_policy = get_authentication_policy(endpoint, credential, is_async=True)
4444

4545
self._sms_service_client = AzureCommunicationSMSService(
4646
self._endpoint,
@@ -94,8 +94,8 @@ async def send(self, from_phone_number, # type: ~azure.communication.sms.PhoneN
9494
send_sms_options = kwargs.pop('send_sms_options', None)
9595

9696
request = SendMessageRequest(
97-
from_property=from_phone_number,
98-
to=to_phone_numbers,
97+
from_property=from_phone_number.phone_number,
98+
to=[p.phone_number for p in to_phone_numbers],
9999
message=message,
100100
send_sms_options=send_sms_options,
101101
**kwargs)

sdk/communication/azure-communication-sms/tests/test_sms_client_e2e_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ async def test_send_sms_async_from_managed_identity(self):
7171
async with sms_client:
7272
# calling send() with sms values
7373
sms_response = await sms_client.send(
74-
from_phone_number=PhoneNumber(self.phone_number),
75-
to_phone_numbers=[PhoneNumber(self.phone_number)],
74+
from_phone_number=PhoneNumberIdentifier(self.phone_number),
75+
to_phone_numbers=[PhoneNumberIdentifier(self.phone_number)],
7676
message="Hello World via SMS",
7777
send_sms_options=SendSmsOptions(enable_delivery_report=True)) # optional property
7878

0 commit comments

Comments
 (0)