Skip to content

Commit

Permalink
Reworked tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-beauregard committed Mar 5, 2021
1 parent 2e549c5 commit 545fcb0
Show file tree
Hide file tree
Showing 19 changed files with 903 additions and 120 deletions.
4 changes: 2 additions & 2 deletions sdk/communication/azure-communication-phonenumbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ poller = phone_numbers_client.begin_search_available_phone_numbers(
PhoneNumberType.TOLL_FREE,
PhoneNumberAssignmentType.APPLICATION,
capabilities,
"833", # Area code is optional for toll-free numbers
1, # Quantity is optional, default is 1
area_code ="833", # Area code is optional for toll-free numbers
quantity = 2, # Quantity is optional. If not set, default is 1
polling = True
)
search_result = poller.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def begin_release_phone_number(
:param phone_number: Phone number to be released, e.g. +11234567890.
:type phone_number: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
Expand All @@ -109,7 +108,6 @@ def begin_search_available_phone_numbers(
phone_number_type, # type: str
assignment_type, # type: str
capabilities, # type: PhoneNumberCapabilities
quantity=None, # type: int
**kwargs # type: Any
):
# type: (...) -> LROPoller[PhoneNumberSearchResult]
Expand All @@ -127,10 +125,9 @@ def begin_search_available_phone_numbers(
~azure.communication.phonenumbers.models.PhoneNumberAssignmentType
:param capabilities: Required. Capabilities of a phone number.
:type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities
:param quantity: The quantity of phone numbers in the search. Should be at least 1.
:type quantity: int
:keyword str area_code: The area code of the desired phone number, e.g. 425. If not set,
any area code could be used in the final search.
:keyword int quantity: The quantity of phone numbers in the search. Default is 1.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
Expand All @@ -143,7 +140,7 @@ def begin_search_available_phone_numbers(
phone_number_type=phone_number_type,
assignment_type=assignment_type,
capabilities=capabilities,
quantity=quantity,
quantity=kwargs.pop('quantity', None),
area_code=kwargs.pop('area_code', None)
)
return self._phone_number_client.phone_numbers.begin_search_available_phone_numbers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setUp(self):
super(CommunicationTestCase, self).setUp()

if self.is_playback():
self.connection_str = "endpoint=https://sanitized/;accesskey=fake==="
self.connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake==="
else:
self.connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING')
endpoint, _ = parse_connection_str(self.connection_str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ class PhoneNumberUriReplacer(RecordingProcessor):

def process_request(self, request):
import re
request.uri = re.sub('/identities/([^/?]+)', '/identities/sanitized', request.uri)
request.uri = re.sub('phoneNumbers/[%2B\d]+', 'phoneNumbers/sanitized', request.uri)
return request

def process_response(self, response):
import re
if 'url' in response:
response['url'] = re.sub('/identities/([^/?]+)', '/identities/sanitized', response['url'])
response['url'] = re.sub('phonePlanId=([^/?&]+)', 'phonePlanId=sanitized', response['url'])
response['url'] = re.sub('capabilities/([^/?&]+)', 'capabilities/sanitized', response['url'])
response['url'] = re.sub('phoneplangroups/([^/?&]+)', 'phoneplangroups/sanitized', response['url'])
response['url'] = re.sub('phoneplans/([^/?&]+)', 'phoneplans/sanitized', response['url'])
response['url'] = re.sub('releases/([^/?&]+)', 'releases/sanitized', response['url'])
response['url'] = re.sub('searches/([^/?&]+)', 'searches/sanitized', response['url'])
return response
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,32 @@ interactions:
Connection:
- keep-alive
Date:
- Mon, 22 Feb 2021 19:48:24 GMT
- Thu, 04 Mar 2021 20:09:28 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
- 'true'
method: GET
uri: https://sanitized.communication.azure.com/phoneNumbers/%2B18335260208?api-version=2021-03-07
uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized?api-version=2021-03-07
response:
body:
string: '{"id": "sanitized", "phoneNumber": "sanitized", "countryCode": "US",
"phoneNumberType": "TollFree", "capabilities": {"calling": "inbound+outbound",
"sms": "outbound"}, "assignmentType": "Application"}'
"phoneNumberType": "TollFree", "capabilities": {"calling": "inbound", "sms":
"inbound+outbound"}, "assignmentType": "Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}'
headers:
content-type:
- application/json; charset=utf-8
date:
- Mon, 22 Feb 2021 19:48:23 GMT
- Thu, 04 Mar 2021 20:09:30 GMT
ms-cv:
- KQDB5Gt5/EiYmdjzTHoodQ.0
- b1QfQvNXJUCmudxXTNXVYw.0
request-context:
- appId=
transfer-encoding:
- chunked
x-processing-time:
- 847ms
- 1995ms
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interactions:
Connection:
- keep-alive
Date:
- Tue, 02 Mar 2021 22:15:48 GMT
- Thu, 04 Mar 2021 20:09:31 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
Expand All @@ -18,20 +18,20 @@ interactions:
uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07
response:
body:
string: '{"phoneNumbers": "sanitized"}'
string: '{"phoneNumbers": ["sanitized"]}'
headers:
content-type:
- application/json; charset=utf-8
date:
- Tue, 02 Mar 2021 22:15:52 GMT
- Thu, 04 Mar 2021 20:09:34 GMT
ms-cv:
- 1414CoW0X0iYJWEiELIX2A.0
- Aa07dXCJ1Eiv8sLy5yURtA.0
request-context:
- appId=
transfer-encoding:
- chunked
x-processing-time:
- 4208ms
- 4239ms
status:
code: 200
message: OK
Expand Down
Loading

0 comments on commit 545fcb0

Please sign in to comment.