Skip to content

Commit e9a1b5a

Browse files
Update test_conferences.py
1 parent 8914950 commit e9a1b5a

File tree

1 file changed

+2
-99
lines changed

1 file changed

+2
-99
lines changed

test/integration/test_conferences.py

Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
Integration tests for Bandwidth's Voice Voice Conferences API
33
"""
44

5-
from test.utils.env_variables import *
6-
from test.utils.call_cleanup import callCleanup
75
import json
86
import time
97
from typing import List, Tuple
108
import unittest
119
from hamcrest import assert_that, has_properties, not_none, instance_of, greater_than
12-
13-
1410
import bandwidth
1511
from bandwidth.api import calls_api
1612
from bandwidth.model.create_call import CreateCall
@@ -27,6 +23,8 @@
2723
from bandwidth.model.file_format_enum import FileFormatEnum
2824
from bandwidth.rest import RESTClientObject, RESTResponse
2925
from bandwidth.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException
26+
from test.utils.env_variables import *
27+
from test.utils.call_cleanup import callCleanup
3028

3129
class ConferencesIntegration(unittest.TestCase):
3230
"""
@@ -44,20 +42,15 @@ def setUp(self):
4442
)
4543
api_client = bandwidth.ApiClient(configuration)
4644

47-
# Two Valid API Clients
4845
self.calls_api_instance = calls_api.CallsApi(api_client)
4946
self.conference_api_instance = conferences_api.ConferencesApi(api_client)
5047

51-
# Unauthorized API Client
52-
5348
unauthorizedConfiguration = bandwidth.Configuration(
5449
username='bad_username',
5550
password='bad_password'
5651
)
5752
unauthorized_api_client = bandwidth.ApiClient(unauthorizedConfiguration)
5853
self.unauthorized_api_instance = conferences_api.ConferencesApi(unauthorized_api_client)
59-
60-
# Forbidden API Client
6154

6255
forbiddenConfiguration = bandwidth.Configuration(
6356
username=FORBIDDEN_USERNAME,
@@ -102,16 +95,13 @@ def assertApiException(self, context: ApiException, expectedException: ApiExcept
10295
"""Validates that common API exceptions, (401, 403, and 404) are properly formatted
10396
Args:
10497
context (ApiException): Exception to validate
105-
expectedException (ApiException): Expected exception type
10698
expected_status_code (int): Expected status code
10799
"""
108100
assert_that(context.exception, has_properties(
109101
'status', expected_status_code,
110102
'body', not_none()
111103
))
112104

113-
# Create Conference Call with Manteca
114-
115105
def create_conference(self, answer_url: str) -> Tuple[str, str]:
116106
"""
117107
Create and validate a call between two bandwidth numbers. Initializes the call with the Manteca
@@ -135,17 +125,12 @@ def create_conference(self, answer_url: str) -> Tuple[str, str]:
135125
}
136126
)
137127

138-
# Get the test id from the response
139128
test_id = json.loads(response.data)
140129

141-
# Make a CreateCall body and assign the appropriate params
142-
143130
call_body = CreateCall(to=MANTECA_IDLE_NUMBER, _from=MANTECA_ACTIVE_NUMBER, application_id=MANTECA_APPLICATION_ID, answer_url=answer_url, tag=test_id)
144131

145-
# Make the call
146132
create_call_response: CreateCallResponse = self.calls_api_instance.create_call(BW_ACCOUNT_ID, call_body)
147133

148-
# Verify info about the call
149134
assert_that(create_call_response, has_properties(
150135
"call_id", instance_of(str),
151136
'account_id', BW_ACCOUNT_ID,
@@ -154,8 +139,6 @@ def create_conference(self, answer_url: str) -> Tuple[str, str]:
154139
'_from', MANTECA_ACTIVE_NUMBER
155140
))
156141

157-
# Getting our ConferenceId and returning the test_id from Manteca and the callId
158-
159142
list_conferences_response = self.conference_api_instance.list_conferences(BW_ACCOUNT_ID, _return_http_data_only=False)
160143

161144
time.sleep(self.TEST_SLEEP)
@@ -171,12 +154,6 @@ def create_conference(self, answer_url: str) -> Tuple[str, str]:
171154
return (test_id, create_call_response.call_id)
172155

173156
def validate_recording(self, recording: ConferenceRecordingMetadata, conference_id: str) -> None:
174-
"""
175-
Validate the given recording metadata.
176-
Args:
177-
recording (ConferenceRecordingMetadata): The recording metadata to validate.
178-
conference_id (str): The call id associated with the given recording.
179-
"""
180157
assert_that(recording.status,'complete')
181158
assert_that(recording.file_format,FileFormatEnum('wav'))
182159

@@ -192,11 +169,9 @@ def test_conference_and_members(self):
192169
- update_conference_bxml
193170
"""
194171

195-
# Create the call
196172
answer_url = MANTECA_BASE_URL + "/bxml/joinConferencePause"
197173
(test_id, call_id) = self.create_conference(answer_url)
198174

199-
# List Conferences
200175
list_conferences_response = self.conference_api_instance.list_conferences(BW_ACCOUNT_ID, _return_http_data_only=False)
201176

202177
assert_that(list_conferences_response[1], 200)
@@ -205,55 +180,36 @@ def test_conference_and_members(self):
205180

206181
conferenceId = (list_conferences_response[0][len(list_conferences_response[0])-1].id)
207182

208-
# Get Conference Information
209-
"""Validate a Get Conference Information Request
210-
"""
211183
get_conference_response = self.conference_api_instance.get_conference(BW_ACCOUNT_ID, conferenceId, _return_http_data_only=False)
212184
assert_that(get_conference_response[1], 200)
213185
assert_that(get_conference_response[0].id, conferenceId)
214186
assert_that(get_conference_response[0].name, instance_of(str))
215187
callId = (get_conference_response[0].active_members[0].call_id)
216188
self.callIdArray.append(callId)
217189

218-
# Get Conference Member
219-
"""Validate a GET Conference Member
220-
"""
221190
get_conference_member_response = self.conference_api_instance.get_conference_member(BW_ACCOUNT_ID, conferenceId, callId, _return_http_data_only=False)
222191
assert_that(get_conference_member_response[1], 200)
223192
assert_that(get_conference_member_response[0].conference_id, conferenceId)
224193
assert_that(get_conference_member_response[0].call_id, callId)
225194

226-
# Update Conference Member
227-
"""Validate an Update Conference Member Request
228-
"""
229-
230195
time.sleep(self.TEST_SLEEP)
231196
update_conference_member_response = self.conference_api_instance.update_conference_member(BW_ACCOUNT_ID, conferenceId, callId, self.testUpdateMember, _return_http_data_only=False)
232197
assert_that(update_conference_member_response[1], 204)
233198

234-
# Update Conference
235-
"""Validate an Update Conference Request
236-
"""
237-
238199
time.sleep(self.TEST_SLEEP)
239200
update_conference_response = self.conference_api_instance.update_conference(BW_ACCOUNT_ID, conferenceId, self.testUpdateConf, _return_http_data_only=False)
240201
assert_that(update_conference_response[1], 204)
241202

242203

243-
# Update Conference Bxml
244-
"""Validate an UpdateConferencelBxml Request
245-
"""
246204
updateBxmlBody = '<?xml version="1.0" encoding="UTF-8"?><Bxml><SpeakSentence locale="en_US" gender="female" voice="susan">This is a test bxml response</SpeakSentence></Bxml>'
247205

248206
time.sleep(self.TEST_SLEEP)
249207
update_conference_bxml_response = self.conference_api_instance.update_conference_bxml(BW_ACCOUNT_ID, conferenceId, updateBxmlBody, _return_http_data_only=False)
250208
assert_that(update_conference_bxml_response[1], 204)
251209

252-
# Kill the call
253210
update_call = UpdateCall(state=CallStateEnum('completed'))
254211
self.calls_api_instance.update_call(BW_ACCOUNT_ID, call_id, update_call, _return_http_data_only=False)
255212

256-
# Conference Recordings Tests
257213
def test_conference_recordings(self) -> None:
258214
"""
259215
Tests a successful flow of creating a call with a recording.
@@ -263,7 +219,6 @@ def test_conference_recordings(self) -> None:
263219
- download_conference_recording
264220
"""
265221

266-
# Create a conference and have it recorded
267222
answer_url = MANTECA_BASE_URL + "/bxml/joinConferencePause"
268223
(test_id, call_id) = self.create_conference(answer_url)
269224

@@ -272,29 +227,22 @@ def test_conference_recordings(self) -> None:
272227
assert_that(list_conferences_response[1], 200)
273228
conferenceId = (list_conferences_response[0][len(list_conferences_response[0])-1].id)
274229

275-
# Update Conference Bxml
276-
"""Validate an UpdateConferencelBxml Request to start and stop recording
277-
"""
278230
updateBxmlBody = '<?xml version="1.0" encoding="UTF-8"?><Bxml><StartRecording/><SpeakSentence locale="en_US" gender="female" voice="susan">This should be a conference recording.</SpeakSentence><StopRecording/></Bxml>'
279231
update_conference_bxml_response = self.conference_api_instance.update_conference_bxml(BW_ACCOUNT_ID, conferenceId, updateBxmlBody, _return_http_data_only=False)
280232
assert_that(update_conference_bxml_response[1], 204)
281233

282234
time.sleep(self.TEST_SLEEP_LONG)
283235

284-
# List Conference Recordings Endpoint
285236
list_conference_recordings_response: List[ConferenceRecordingMetadata] = self.conference_api_instance.list_conference_recordings(BW_ACCOUNT_ID, conferenceId, _return_http_data_only=False)
286237
assert_that(list_conference_recordings_response[1],200)
287238

288-
# We should get back at least 1 recording
289239
conference_recordings = list_conference_recordings_response[0]
290240
assert_that(len(conference_recordings), greater_than(0))
291241

292-
# Checks on the first recording
293242
first_recording: ConferenceRecordingMetadata = conference_recordings[0]
294243
self.validate_recording(first_recording, conferenceId)
295244
recording_id = first_recording.recording_id
296245

297-
# Get Single Recording Endpoint
298246
recording_response: ConferenceRecordingMetadata = self.conference_api_instance.get_conference_recording(BW_ACCOUNT_ID, conferenceId, recording_id, _return_http_data_only=False)
299247
assert_that(recording_response[1], 200)
300248
assert_that(recording_response[0].conference_id, conferenceId)
@@ -303,181 +251,136 @@ def test_conference_recordings(self) -> None:
303251

304252
self.validate_recording(recording_response[0], conferenceId)
305253

306-
# Download recording media
307254
recording_media_response = self.conference_api_instance.download_conference_recording(BW_ACCOUNT_ID, conferenceId, recording_id, _preload_content=False)
308255
conference_recording_media = recording_media_response.data
309256

310257
def test_list_conferences_unauthorized(self) -> None:
311-
"""Validate an unauthorized (401) request
312-
"""
313258
with self.assertRaises(UnauthorizedException) as context:
314259
self.unauthorized_api_instance.list_conferences(BW_ACCOUNT_ID, _return_http_data_only=False)
315260

316261
self.assertApiException(context, UnauthorizedException, 401)
317262

318263
def test_list_conferences_forbidden(self) -> None:
319-
"""Validate a forbidden (403) request
320-
"""
321264
with self.assertRaises(ForbiddenException) as context:
322265
self.forbidden_api_instance.list_conferences(BW_ACCOUNT_ID, _return_http_data_only=False)
323266

324267
self.assertApiException(context, ForbiddenException, 403)
325268

326269
def test_get_conferences_unauthorized(self) -> None:
327-
"""Validate an unauthorized (401) Get Conference Information
328-
"""
329270
with self.assertRaises(UnauthorizedException) as context:
330271
self.unauthorized_api_instance.get_conference(BW_ACCOUNT_ID, self.testConfId, _return_http_data_only=False)
331272

332273
self.assertApiException(context, UnauthorizedException, 401)
333274

334275
def test_get_conferences_forbidden(self) -> None:
335-
"""Validate a forbidden (403) Get Conference Information request
336-
"""
337276
with self.assertRaises(ForbiddenException) as context:
338277
self.forbidden_api_instance.get_conference(BW_ACCOUNT_ID, self.testConfId, _return_http_data_only=False)
339278

340279
self.assertApiException(context, ForbiddenException, 403)
341280

342281
def test_get_conferences_not_found(self) -> None:
343-
"""Validate an invalid Get Conference Information Request due to a bad conferenceId
344-
"""
345282
with self.assertRaises(NotFoundException) as context:
346283
self.conference_api_instance.get_conference(BW_ACCOUNT_ID, self.testConfId, _return_http_data_only=False)
347284

348285
self.assertApiException(context, NotFoundException, 404)
349286

350287
def test_get_conference_member_unauthorized(self) -> None:
351-
"""Validate an unauthorized (401) Get Conference Member
352-
"""
353288
with self.assertRaises(UnauthorizedException) as context:
354289
self.unauthorized_api_instance.get_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testMemberId, _return_http_data_only=False)
355290

356291
self.assertApiException(context, UnauthorizedException, 401)
357292

358293
def test_get_conference_member_forbidden(self) -> None:
359-
"""Validate an forbidden (403) Get Conference Member
360-
"""
361294
with self.assertRaises(ForbiddenException) as context:
362295
self.forbidden_api_instance.get_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testMemberId, _return_http_data_only=False)
363296

364297
self.assertApiException(context, ForbiddenException, 403)
365298

366299
def test_get_conference_member_not_found(self) -> None:
367-
"""Validate an not found (404) Get Conference Member
368-
"""
369300
with self.assertRaises(NotFoundException) as context:
370301
self.conference_api_instance.get_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testMemberId, _return_http_data_only=False)
371302

372303
self.assertApiException(context, NotFoundException, 404)
373304

374305
def test_list_conference_recordings_unauthorized(self) -> None:
375-
"""Validate an unauthorized (401) request
376-
"""
377306
with self.assertRaises(UnauthorizedException) as context:
378307
self.unauthorized_api_instance.list_conference_recordings(BW_ACCOUNT_ID, self.testConfId, _return_http_data_only=False)
379308

380309
self.assertApiException(context, UnauthorizedException, 401)
381310

382311
def test_list_conference_recordings_forbidden(self) -> None:
383-
"""Validate a forbidden (403) request
384-
"""
385312
with self.assertRaises(ForbiddenException) as context:
386313
self.forbidden_api_instance.list_conference_recordings(BW_ACCOUNT_ID, self.testConfId, _return_http_data_only=False)
387314

388315
self.assertApiException(context, ForbiddenException, 403)
389316

390317
def test_get_recording_unauthorized(self) -> None:
391-
"""Validate an unauthorized (401) Get Conference Recording
392-
"""
393318
with self.assertRaises(UnauthorizedException) as context:
394319
self.unauthorized_api_instance.get_conference_recording(BW_ACCOUNT_ID, self.testConfId, self.testRecordId, _return_http_data_only=False)
395320

396321
self.assertApiException(context, UnauthorizedException, 401)
397322

398323
def test_get_recording_forbidden(self) -> None:
399-
"""Validate an forbidden (403) Get Conference Recording
400-
"""
401324
with self.assertRaises(ForbiddenException) as context:
402325
self.forbidden_api_instance.get_conference_recording(BW_ACCOUNT_ID, self.testConfId, self.testRecordId, _return_http_data_only=False)
403326

404327
self.assertApiException(context, ForbiddenException, 403)
405328

406329
def test_get_conference_recording_not_found(self) -> None:
407-
"""Validate an not found (404) Get Conference Recording
408-
"""
409330
with self.assertRaises(NotFoundException) as context:
410331
self.conference_api_instance.get_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testRecordId, _return_http_data_only=False)
411332

412333
self.assertApiException(context, NotFoundException, 404)
413334

414335
def test_update_conference_unauthorized(self) -> None:
415-
"""Validate an unauthorized (401) Update Conference
416-
"""
417336
with self.assertRaises(UnauthorizedException) as context:
418337
self.unauthorized_api_instance.update_conference(BW_ACCOUNT_ID, self.testConfId, self.testUpdateConf, _return_http_data_only=False)
419338

420339
self.assertApiException(context, UnauthorizedException, 401)
421340

422341
def test_update_conference_forbidden(self) -> None:
423-
"""Validate an forbidden (403) Update Conference
424-
"""
425342
with self.assertRaises(ForbiddenException) as context:
426343
self.forbidden_api_instance.update_conference(BW_ACCOUNT_ID, self.testConfId, self.testUpdateConf, _return_http_data_only=False)
427344

428345
self.assertApiException(context, ForbiddenException, 403)
429346

430347
def test_update_conference_not_found(self) -> None:
431-
"""Validate an not found (404) Update Conference
432-
"""
433348
with self.assertRaises(NotFoundException) as context:
434349
self.conference_api_instance.update_conference(BW_ACCOUNT_ID, self.testConfId, self.testUpdateConf, _return_http_data_only=False)
435350

436351
self.assertApiException(context, NotFoundException, 404)
437352

438353
def test_update_conference_bxml_unauthorized(self) -> None:
439-
"""Validate an unauthorized (401) Update Conference BXML
440-
"""
441354
with self.assertRaises(UnauthorizedException) as context:
442355
self.unauthorized_api_instance.update_conference_bxml(BW_ACCOUNT_ID, self.testConfId, self.testUpdateBxml, _return_http_data_only=False)
443356

444357
self.assertApiException(context, UnauthorizedException, 401)
445358

446359
def test_update_conference_bxml_forbidden(self) -> None:
447-
"""Validate an forbidden (403) Update Conference BXML
448-
"""
449360
with self.assertRaises(ForbiddenException) as context:
450361
self.forbidden_api_instance.update_conference_bxml(BW_ACCOUNT_ID, self.testConfId, self.testUpdateBxml, _return_http_data_only=False)
451362

452363
self.assertApiException(context, ForbiddenException, 403)
453364

454365
def test_update_conference_bxml_not_found(self) -> None:
455-
"""Validate an not found (404) Update Conference BXML
456-
"""
457366
with self.assertRaises(NotFoundException) as context:
458367
self.conference_api_instance.update_conference_bxml(BW_ACCOUNT_ID, self.testConfId, self.testUpdateBxml, _return_http_data_only=False)
459368

460369
self.assertApiException(context, NotFoundException, 404)
461370

462371
def test_update_conference_member_unauthorized(self) -> None:
463-
"""Validate an unauthorized (401) Get Conference Member
464-
"""
465372
with self.assertRaises(UnauthorizedException) as context:
466373
self.unauthorized_api_instance.update_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testMemberId, self.testUpdateMember, _return_http_data_only=False)
467374

468375
self.assertApiException(context, UnauthorizedException, 401)
469376

470377
def test_update_conference_member_forbidden(self) -> None:
471-
"""Validate an forbidden (403) Get Conference Member
472-
"""
473378
with self.assertRaises(ForbiddenException) as context:
474379
self.forbidden_api_instance.update_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testMemberId, self.testUpdateMember, _return_http_data_only=False)
475380

476381
self.assertApiException(context, ForbiddenException, 403)
477382

478383
def test_update_conference_member_not_found(self) -> None:
479-
"""Validate an not found (404) Get Conference Member
480-
"""
481384
with self.assertRaises(NotFoundException) as context:
482385
self.conference_api_instance.update_conference_member(BW_ACCOUNT_ID, self.testConfId, self.testMemberId, self.testUpdateMember, _return_http_data_only=False)
483386

0 commit comments

Comments
 (0)