Skip to content

Commit 45d756f

Browse files
Update test_calls.py
1 parent 208fb78 commit 45d756f

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

test/integration/test_calls.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
from email.quoprimime import body_check
66
import os
7-
import json
87
import time
98
import unittest
109
import datetime
11-
import pytest
1210

1311

1412
import bandwidth
@@ -75,6 +73,7 @@ def assertApiException(self, context: ApiException, expectedException: ApiExcept
7573
def test_create_call(self):
7674
"""Validate a Create Call request with all optional parameters
7775
"""
76+
time.sleep(2)
7877
answer_url = BASE_CALLBACK_URL
7978
call_body = CreateCall(
8079
to=USER_NUMBER,
@@ -124,8 +123,6 @@ def test_create_call(self):
124123
self.assertEqual(create_call_response[0].call_url, ("https://voice.bandwidth.com/api/v2/accounts/" + \
125124
BW_ACCOUNT_ID + "/calls/" + create_call_response[0].call_id))
126125

127-
time.sleep(1)
128-
129126
def test_create_call_bad_request(self):
130127
"""Validate a bad (400) request
131128
"""
@@ -155,8 +152,6 @@ def test_create_call_unauthorized(self) -> None:
155152

156153
self.assertApiException(context, UnauthorizedException, 401)
157154

158-
time.sleep(2)
159-
160155
def test_create_call_forbidden(self) -> None:
161156
"""Validate a forbidden (403) request
162157
"""
@@ -175,11 +170,11 @@ def test_create_call_forbidden(self) -> None:
175170

176171
self.assertApiException(context, ForbiddenException, 403)
177172

178-
time.sleep(2)
179173

180174
def test_get_call_state(self):
181175
"""Validate an Get Call State Request
182176
"""
177+
time.sleep(2)
183178
answer_url = BASE_CALLBACK_URL
184179
call_body = CreateCall(to=USER_NUMBER, _from=BW_NUMBER, application_id=BW_VOICE_APPLICATION_ID, answer_url=answer_url)
185180
create_call_response: CreateCallResponse = self.api_instance.create_call(BW_ACCOUNT_ID, call_body, _return_http_data_only=False)
@@ -212,8 +207,6 @@ def test_get_call_state_unauthorized(self) -> None:
212207

213208
self.assertApiException(context, UnauthorizedException, 401)
214209

215-
time.sleep(2)
216-
217210
def test_get_call_state_forbidden(self) -> None:
218211
"""Validate a forbidden (403) request
219212
"""
@@ -230,9 +223,7 @@ def test_get_call_state_forbidden(self) -> None:
230223
with self.assertRaises(ForbiddenException) as context:
231224
forbidden_api_instance.get_call_state(BW_ACCOUNT_ID, call_id, _return_http_data_only=False)
232225

233-
self.assertApiException(context, ForbiddenException, 403)
234-
235-
time.sleep(2)
226+
self.assertApiException(context, ForbiddenException, 403)
236227

237228
def test_get_call_state_not_found(self):
238229
"""Validate an invalid Get Call State Request due to a bad callID
@@ -245,7 +236,8 @@ def test_get_call_state_not_found(self):
245236

246237
def test_update_call(self):
247238
"""Validate an UpdateCall Request
248-
"""
239+
"""
240+
time.sleep(2)
249241
answer_url = MANTECA_BASE_URL + "/bxml/loop"
250242
call_body = CreateCall(to=MANTECA_IDLE_NUMBER, _from=MANTECA_ACTIVE_NUMBER, application_id=MANTECA_APPLICATION_ID, answer_url=answer_url)
251243
create_call_response: CreateCallResponse = self.api_instance.create_call(BW_ACCOUNT_ID, call_body, _return_http_data_only=False)
@@ -280,12 +272,17 @@ def test_update_call_bad_request(self):
280272
call_body = CreateCall(to=MANTECA_IDLE_NUMBER, _from=MANTECA_ACTIVE_NUMBER, application_id=MANTECA_APPLICATION_ID, answer_url=answer_url)
281273
create_call_response: CreateCallResponse = self.api_instance.create_call(BW_ACCOUNT_ID, call_body, _return_http_data_only=False)
282274
call_id = create_call_response[0].call_id
283-
body = UpdateCall(state=CallStateEnum("completed"))
275+
body = UpdateCall(states="badReqeust")
276+
body2 = UpdateCall(state=CallStateEnum("completed"))
284277

285278
with self.assertRaises(ApiException) as context:
286279
self.api_instance.update_call(BW_ACCOUNT_ID, call_id, body, _return_http_data_only=False)
287280

288-
self.assertEqual(context.exception.status, 400)
281+
self.assertEqual(context.exception.status, 400)
282+
283+
# hanging-up the call
284+
update_call_response: UpdateCall = self.api_instance.update_call(BW_ACCOUNT_ID, call_id, body2, _return_http_data_only=False)
285+
self.assertEqual(update_call_response[1], 200)
289286

290287
def test_update_call_unauthorized(self):
291288
"""Validate an unauthorized (401) update call request
@@ -305,8 +302,6 @@ def test_update_call_unauthorized(self):
305302

306303
self.assertApiException(context, UnauthorizedException, 401)
307304

308-
time.sleep(2)
309-
310305
def test_update_call_forbidden(self):
311306
"""Validate a forbidden (403) update call request
312307
"""
@@ -327,9 +322,7 @@ def test_update_call_forbidden(self):
327322
with self.assertRaises(ForbiddenException) as context:
328323
forbidden_api_instance.update_call(BW_ACCOUNT_ID, call_id, body, _return_http_data_only=False)
329324

330-
self.assertApiException(context, ForbiddenException, 403)
331-
332-
time.sleep(2)
325+
self.assertApiException(context, ForbiddenException, 403)
333326

334327
def test_update_call_not_found(self):
335328
"""Validate a not found update call request
@@ -344,7 +337,8 @@ def test_update_call_not_found(self):
344337

345338
def test_update_call_bxml(self):
346339
"""Validate an UpdateCallBxml Request
347-
"""
340+
"""
341+
time.sleep(2)
348342
answer_url = MANTECA_BASE_URL + "/bxml/loop"
349343
call_body = CreateCall(to=MANTECA_IDLE_NUMBER, _from=MANTECA_ACTIVE_NUMBER, application_id=MANTECA_APPLICATION_ID, answer_url=answer_url)
350344
create_call_response: CreateCallResponse = self.api_instance.create_call(BW_ACCOUNT_ID, call_body, _return_http_data_only=False)
@@ -394,8 +388,6 @@ def test_update_call_bxml_unauthorized(self):
394388

395389
self.assertApiException(context, UnauthorizedException, 401)
396390

397-
time.sleep(2)
398-
399391
def test_update_call_bxml_forbidden(self):
400392
"""Validate a forbidden (403) update call bxml request
401393
"""
@@ -418,8 +410,6 @@ def test_update_call_bxml_forbidden(self):
418410

419411
self.assertApiException(context, ForbiddenException, 403)
420412

421-
time.sleep(2)
422-
423413
def test_update_call_bxml_not_found(self):
424414
"""Validate a not found update call bxml request
425415
"""

0 commit comments

Comments
 (0)