diff --git a/sdk/communication/azure-communication-administration/tests/_shared/fake_token_credential.py b/sdk/communication/azure-communication-administration/tests/_shared/fake_token_credential.py new file mode 100644 index 0000000000000..b4fc2e6eaccfa --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/_shared/fake_token_credential.py @@ -0,0 +1,13 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from azure.core.credentials import AccessToken + +class FakeTokenCredential(object): + def __init__(self): + self.token = AccessToken("Fake Token", 0) + + def get_token(self, *args): + return self.token \ No newline at end of file diff --git a/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py index 30b3480ec193c..2ba471cb97e72 100644 --- a/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py +++ b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py @@ -16,18 +16,13 @@ from phone_number_helper import PhoneNumberUriReplacer from phone_number_testcase import PhoneNumberCommunicationTestCase from _shared.testcase import BodyReplacerProcessor +from _shared.fake_token_credential import FakeTokenCredential from azure.identity import DefaultAzureCredential from azure.communication.administration._shared.utils import parse_connection_str SKIP_PHONE_NUMBER_TESTS = True PHONE_NUMBER_TEST_SKIP_REASON= "Phone Number Administration live tests infra not ready yet" -class FakeTokenCredential(object): - def __init__(self): - self.token = AccessToken("Fake Token", 0) - - def get_token(self, *args): - return self.token class PhoneNumberAdministrationClientTest(PhoneNumberCommunicationTestCase): def setUp(self): super(PhoneNumberAdministrationClientTest, self).setUp() diff --git a/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py index 09e60b2ad48df..36db8900e9bbe 100644 --- a/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py +++ b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py @@ -5,7 +5,6 @@ # license information. # -------------------------------------------------------------------------- import pytest -from azure.core.credentials import AccessToken from azure.communication.administration.aio import PhoneNumberAdministrationClient from azure.communication.administration._shared.utils import parse_connection_str from azure.communication.administration import ( @@ -16,18 +15,13 @@ from phone_number_helper import PhoneNumberUriReplacer from phone_number_testcase_async import AsyncPhoneNumberCommunicationTestCase from _shared.testcase import BodyReplacerProcessor, ResponseReplacerProcessor +from _shared.fake_token_credential import FakeTokenCredential from azure.identity import DefaultAzureCredential import os SKIP_PHONE_NUMBER_TESTS = True PHONE_NUMBER_TEST_SKIP_REASON= "Phone Number Administration live tests infra not ready yet" -class FakeTokenCredential(object): - def __init__(self): - self.token = AccessToken("Fake Token", 0) - - def get_token(self, *args): - return self.token class PhoneNumberAdministrationClientTestAsync(AsyncPhoneNumberCommunicationTestCase): def setUp(self):