Skip to content

Commit 68115bc

Browse files
DX-2232 Add Matrix Testing (#33)
* DX-2232 Add Matrix Testing * Update validate.yaml * Only support python 3.6 and above * Update OS tests * Update requirements.txt * install from test-requirements * Update validate.yaml * Force urllib version * Update requirements.txt * Add print to check verify "To" TN * Add Manual Trigger * use random seed for MFA verify test * Add back in windows OS * Remove ubuntu-18.04 * add back ubuntu to check bxml * force python3 * force pip3 * Set up python * Update validate.yaml * Update validate.yaml * Update validate.yaml * Adjust test for python 3.6 * Update test_api.py * Remove Validate Action * Rename Validate to Test * Update name * nvm * Update .github/workflows/test.yaml Co-authored-by: Mike Hamer <[email protected]> Co-authored-by: Mike Hamer <[email protected]>
1 parent fa0b4f7 commit 68115bc

File tree

8 files changed

+61
-38
lines changed

8 files changed

+61
-38
lines changed

.github/actions/validate/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/actions/validate/action.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/actions/validate/entrypoint.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1-
name: Validate SDK
1+
name: Test SDK
22

33
on:
44
schedule:
55
- cron: "0 4 * * *"
66
pull_request:
7+
workflow_dispatch:
78

89
jobs:
910
deploy:
10-
name: Validate
11-
runs-on: ubuntu-latest
11+
name: Test
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [windows-2016, windows-2019, ubuntu-18.04, ubuntu-20.04]
16+
python-version: [3.6, 3.7, 3.8, 3.9]
1217
steps:
1318
- name: Checkout
1419
uses: actions/checkout@v2
15-
- name: Validate
16-
uses: ./.github/actions/validate
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install Packages
27+
run: pip install -r requirements.txt
28+
29+
- name: Test
1730
env:
1831
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
1932
BW_USERNAME: ${{ secrets.BW_USERNAME }}
@@ -23,7 +36,10 @@ jobs:
2336
BW_NUMBER: ${{ secrets.BW_NUMBER }}
2437
USER_NUMBER: ${{ secrets.USER_NUMBER }}
2538
BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }}
26-
- uses: Bandwidth/[email protected]
39+
run: python -m pytest --pyargs bandwidth
40+
41+
- name: Notify Slack of Failures
42+
uses: Bandwidth/[email protected]
2743
if: failure() && !github.event.pull_request.draft
2844
with:
2945
job-status: ${{ job.status }}

bandwidth/tests/test_api.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import time
1010
import pytest
11-
from datetime import datetime
11+
import dateutil.parser
1212
from random import seed
1313
from random import randint
1414
from bandwidth.bandwidth_client import BandwidthClient
@@ -30,7 +30,7 @@
3030
log_cli = True
3131

3232
# seed the random number generator
33-
seed(1)
33+
seed(randint(10, 500))
3434

3535
try:
3636
BW_USERNAME = os.environ["BW_USERNAME"]
@@ -124,7 +124,7 @@ def test_successful_create_message(self, messaging_client):
124124
assert create_response_body.application_id == BW_MESSAGING_APPLICATION_ID
125125

126126
# asserts the date string is valid ISO
127-
assert datetime.fromisoformat(create_response_body.time.replace('Z', '+00:00'))
127+
assert dateutil.parser.isoparse(str(create_response_body.time))
128128
assert type(create_response_body.segment_count) is int
129129
assert create_response_body.to == [USER_NUMBER]
130130
assert create_response_body.media == message_body.media
@@ -235,7 +235,7 @@ def test_successful_create_and_get_call(self, voice_client):
235235
assert create_response_body.mfrom == BW_NUMBER
236236
assert create_response_body.call_url == "https://voice.bandwidth.com/api/v2/accounts/" + \
237237
BW_ACCOUNT_ID + "/calls/" + create_response_body.call_id
238-
assert datetime.fromisoformat(str(create_response_body.start_time)) # assert that str(start_time) is datetime
238+
assert dateutil.parser.isoparse(str(create_response_body.start_time)) # assert that str(start_time) is datetime
239239
assert type(create_response_body.call_timeout) is float
240240
assert type(create_response_body.callback_timeout) is float
241241
assert create_response_body.answer_method == "POST"
@@ -244,12 +244,12 @@ def test_successful_create_and_get_call(self, voice_client):
244244
assert get_response_body.call_id == create_response_body.call_id
245245
assert get_response_body.application_id == BW_VOICE_APPLICATION_ID
246246
assert get_response_body.account_id == BW_ACCOUNT_ID
247-
assert datetime.fromisoformat(str(get_response_body.start_time))
248-
assert datetime.fromisoformat(str(get_response_body.last_update))
247+
assert dateutil.parser.isoparse(str(get_response_body.start_time))
248+
assert dateutil.parser.isoparse(str(get_response_body.last_update))
249249
if get_response_body.answer_time: # may be null dependent on timing
250-
assert datetime.fromisoformat(str(get_response_body.answer_time))
250+
assert dateutil.parser.isoparse(str(get_response_body.answer_time))
251251
if get_response_body.end_time: # may be null dependent on timing
252-
assert datetime.fromisoformat(str(get_response_body.end_time))
252+
assert dateutil.parser.isoparse(str(get_response_body.end_time))
253253
if get_response_body.disconnect_cause == "error":
254254
assert type(get_response_body.error_message) is str
255255
assert len(get_response_body.error_id) == 36
@@ -425,6 +425,9 @@ def test_failed_mfa_verify(self, mfa_client):
425425
code="123456",
426426
expiration_time_in_minutes=3
427427
)
428+
429+
print(body.to)
430+
428431
verify_response = mfa_client.create_verify_two_factor(BW_ACCOUNT_ID, body)
429432
verify_response_body = verify_response.body
430433

bandwidth/tests/test_bxml.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ def test_transfer(self):
274274
)
275275
response.add_verb(transfer)
276276
expected_bxml = f'<?xml version="1.0" encoding="UTF-8"?><Response><Transfer transferCallerId="+15555555555" callTimeout="50" tag="tag" transferCompleteUrl="https://transcribe.url.server/complete" transferCompleteMethod="POST" username="user" password="pass" diversionTreatment="propagate" diversionReason="away" transferCompleteFallbackUrl="https://test.com" transferCompleteFallbackMethod="GET" fallbackUsername="fusern" fallbackPassword="fpassw">{phone1_bxml}{phone2_bxml}</Transfer></Response>'
277+
278+
print(response.to_bxml())
279+
print(expected_bxml)
280+
277281
assert response.to_bxml() == expected_bxml
278282

279283
def test_conference(self):

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
requests~=2.24
1+
requests>=2.25
22
jsonpickle~=1.4, >= 1.4.1
33
cachecontrol~=0.12.6
44
python-dateutil~=2.8.1
55
enum34~=1.1, >=1.1.10
6-
lxml==4.6.3
7-
pytest==6.2.5
6+
lxml>==4.6.3
7+
pytest>==6.2.5
8+
urllib3>=1.26

test-requirements.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
attrs==21.2.0
2+
CacheControl==0.12.6
3+
certifi==2021.5.30
4+
charset-normalizer==2.0.6
5+
enum34==1.1.10
6+
idna==3.2
7+
iniconfig==1.1.1
8+
jsonpickle==0.9.6
9+
lxml==4.6.3
10+
msgpack==1.0.2
11+
packaging==21.0
12+
pluggy==1.0.0
13+
py==1.10.0
14+
pyparsing==2.4.7
15+
pytest==6.2.5
16+
python-dateutil==2.8.2
17+
requests==2.26.0
18+
six==1.16.0
19+
toml==0.10.2
20+
urllib3==1.26.6

0 commit comments

Comments
 (0)