Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-beauregard committed Jan 28, 2021
1 parent aa29772 commit 376ba75
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -------------------------------------------------------------------------
from .fake_token_credential import FakeTokenCredential
from azure.identity import DefaultAzureCredential

def create_token_credential():
# type: () -> FakeTokenCredential or DefaultAzureCredential
from devtools_testutils import is_live
if not is_live():
return FakeTokenCredential()
return DefaultAzureCredential()
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Tue, 26 Jan 2021 18:56:12 GMT
- Thu, 28 Jan 2021 18:48:48 GMT
ms-cv:
- fqvIVn7QTU2rhudQ0Xygaw.0
- /rMw3sZH40i74G71li+lDA.0
request-context:
- appId=
transfer-encoding:
- chunked
x-processing-time:
- 824ms
- 1124ms
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ interactions:
string: '{"phoneNumbers": "sanitized", "nextLink": null}'
headers:
content-type: application/json; charset=utf-8
date: Tue, 26 Jan 2021 19:56:21 GMT
ms-cv: zqvTNGtq40i4vqZgCLIwLQ.0
date: Thu, 28 Jan 2021 18:49:47 GMT
ms-cv: jqpEP/JsFUKDau9Y0tMhbw.0
request-context: appId=
transfer-encoding: chunked
x-processing-time: 1732ms
x-processing-time: 765ms
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@
from phone_number_helper import PhoneNumberUriReplacer
from phone_number_testcase import PhoneNumberCommunicationTestCase
from _shared.testcase import BodyReplacerProcessor
from azure.identity import DefaultAzureCredential
from _shared.utils import create_token_credential
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()
Expand Down Expand Up @@ -137,11 +131,7 @@ def setUp(self):
@pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON)
def test_list_all_phone_numbers_from_managed_identity(self):
endpoint, access_key = parse_connection_str(self.connection_str)
from devtools_testutils import is_live
if not is_live():
credential = FakeTokenCredential()
else:
credential = DefaultAzureCredential()
credential = create_token_credential()
phone_number_client = PhoneNumberAdministrationClient(endpoint, credential)
pages = phone_number_client.list_all_phone_numbers()
assert pages.next()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -16,18 +15,12 @@
from phone_number_helper import PhoneNumberUriReplacer
from phone_number_testcase_async import AsyncPhoneNumberCommunicationTestCase
from _shared.testcase import BodyReplacerProcessor, ResponseReplacerProcessor
from azure.identity import DefaultAzureCredential
from _shared.utils import create_token_credential
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):
Expand Down Expand Up @@ -140,11 +133,7 @@ def setUp(self):
@pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON)
async def test_list_all_phone_numbers_from_managed_identity(self):
endpoint, access_key = parse_connection_str(self.connection_str)
from devtools_testutils import is_live
if not is_live():
credential = FakeTokenCredential()
else:
credential = DefaultAzureCredential()
credential = create_token_credential()
phone_number_client = PhoneNumberAdministrationClient(endpoint, credential)
async with phone_number_client:
pages = phone_number_client.list_all_phone_numbers()
Expand Down

0 comments on commit 376ba75

Please sign in to comment.