зеркало из
1
0
Форкнуть 0

Gfeitosa/enable int improve coverage (#32792)

* Add int environment to test scope

* Fix int test pipeline configuration file name

* Add coverace config to sms package

* Remove sms/_shared files from global coverage report

* Update livetest pipeline to use sms specific configuration for int environment

* Implement extra sms client tests

* Implement extra sms client async tests

* Replace connection string environment variable name to be more consistent with other SDKs
This commit is contained in:
gfeitosa-msft 2023-11-14 10:43:46 +02:00 коммит произвёл GitHub
Родитель 6a57993ac6
Коммит 24b00af805
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 44 добавлений и 12 удалений

Просмотреть файл

@ -23,4 +23,5 @@ exclude_lines =
omit =
*/test*
env*
*/_serialization.py
*/_serialization.py
*/sms/_shared/*

Просмотреть файл

@ -48,7 +48,7 @@ pkgs =
[pytest]
ignore_args=--ignore=.tox --ignore=build --ignore=.eggs
default_args = -rsfE --junitxml={tox_root}/test-junit-{envname}.xml --verbose --durations=10 --ignore=azure {[pytest]ignore_args}
default_args = -rsfE --junitxml={tox_root}/test-junit-{envname}.xml --verbose --cov-branch --durations=10 --ignore=azure {[pytest]ignore_args}
[testenv]
parallel_show_output =True

Просмотреть файл

@ -2,4 +2,4 @@
mypy = false
pyright = false
type_check_samples = false
verifytypes = false
verifytypes = false

Просмотреть файл

@ -26,7 +26,7 @@ sys.path.append("..")
class SmsMultipleRecipientsSample(object):
connection_string = os.getenv("COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING")
connection_string = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")
phone_number = os.getenv("SMS_PHONE_NUMBER")
def send_sms_to_multiple_recipients(self):

Просмотреть файл

@ -27,7 +27,7 @@ sys.path.append("..")
class SmsMultipleRecipientsSampleAsync(object):
connection_string = os.getenv("COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING")
connection_string = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")
phone_number = os.getenv("SMS_PHONE_NUMBER")
async def send_sms_to_multiple_recipients_async(self):

Просмотреть файл

@ -26,7 +26,7 @@ sys.path.append("..")
class SmsSingleRecipientSample(object):
connection_string = os.getenv("COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING")
connection_string = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")
phone_number = os.getenv("SMS_PHONE_NUMBER")
def send_sms_to_single_recipient(self):

Просмотреть файл

@ -27,7 +27,7 @@ sys.path.append("..")
class SmsSingleRecipientSampleAsync(object):
connection_string = os.getenv("COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING")
connection_string = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")
phone_number = os.getenv("SMS_PHONE_NUMBER")
async def send_sms_to_single_recipient_async(self):

Просмотреть файл

@ -28,7 +28,7 @@ sys.path.append("..")
class SmsTokenCredentialAuthSample(object):
connection_string = os.getenv("COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING")
connection_string = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")
phone_number = os.getenv("SMS_PHONE_NUMBER")
def sms_token_credential_auth(self):

Просмотреть файл

@ -29,7 +29,7 @@ sys.path.append("..")
class SmsTokenCredentialAuthSampleAsync(object):
connection_string = os.getenv("COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING")
connection_string = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")
phone_number = os.getenv("SMS_PHONE_NUMBER")
async def sms_token_credential_auth_async(self):

Просмотреть файл

@ -6,6 +6,7 @@ stages:
BuildTargetingString: 'azure-communication-sms'
JobName: sms
ServiceDirectory: communication
Clouds: Public,Int
CloudConfig:
Public:
SubscriptionConfigurations:
@ -14,7 +15,11 @@ stages:
- $(sub-config-communication-services-sms-cloud-test-resources)
MatrixReplace:
- TestSamples=.*/true
Clouds: Public
Int:
SubscriptionConfigurations:
- $(sub-config-communication-int-test-resources-common)
- $(sub-config-communication-int-test-resources-python)
- $(sub-config-communication-sms-int-test-resources)
EnvVars:
AZURE_SKIP_LIVE_RECORDING: 'True'
AZURE_TEST_RUN_LIVE: 'True'

Просмотреть файл

@ -22,7 +22,7 @@ class ACSSMSTestCase(AzureRecordedTestCase):
def _get_connection_str(self):
if self.is_playback():
return "endpoint=https://sanitized.communication.azure.com/;accesskey=fake==="
return os.getenv('COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING')
return os.getenv('COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING')
def verify_successful_sms_response(self, sms_response):
if self.is_live:

Просмотреть файл

@ -37,7 +37,7 @@ def add_sanitizers(test_proxy):
set_default_session_settings()
add_oauth_response_sanitizer()
connection_str = os.environ.get('COMMUNICATION_SMS_LIVETEST_DYNAMIC_CONNECTION_STRING')
connection_str = os.environ.get('COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING')
if connection_str is not None:
endpoint, _ = parse_connection_str(connection_str)
resource_name = endpoint.split(".")[0]

Просмотреть файл

@ -18,7 +18,20 @@ class FakeTokenCredential(object):
def get_token(self, *args, **kwargs):
return self.token
class TestSMSClient(unittest.TestCase):
def test_invalid_url(self):
with self.assertRaises(ValueError) as context:
SmsClient(None, FakeTokenCredential(), transport=Mock())
self.assertTrue("Account URL must be a string." in str(context.exception))
def test_invalid_credential(self):
with self.assertRaises(ValueError) as context:
SmsClient("endpoint", None, transport=Mock())
self.assertTrue("invalid credential from connection string." in str(context.exception))
def test_send_message(self):
phone_number = "+14255550123"
raised = False

Просмотреть файл

@ -18,7 +18,20 @@ class FakeTokenCredential(object):
async def get_token(self, *args, **kwargs):
return self.token
class TestSMSClientAsync(aiounittest.AsyncTestCase):
def test_invalid_url(self):
with self.assertRaises(ValueError) as context:
SmsClient(None, FakeTokenCredential(), transport=Mock())
self.assertTrue("Account URL must be a string." in str(context.exception))
def test_invalid_credential(self):
with self.assertRaises(ValueError) as context:
SmsClient("endpoint", None, transport=Mock())
self.assertTrue("invalid credential from connection string." in str(context.exception))
async def test_send_message_async(self):
phone_number = "+14255550123"
raised = False