-
Notifications
You must be signed in to change notification settings - Fork 9
DX-2690, DX-2693 webrtc_api Integration Tests #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0cb33fb
DX-2690, DX-2693 `webrtc_api` Integration Tests
ckoegel a334aaa
Merge branch 'feature/openapi-generator-sdk' of https://github.com/Ba…
ckoegel 1813fef
revert files
ckoegel 327e4cb
push what i have rn
ckoegel e43f6e8
most of happy path done
ckoegel 223d3b5
happy path done
ckoegel 38c1937
add notFound and unauthorized exception assertions
ckoegel 75cdadf
Merge branch 'feature/openapi-generator-sdk' of https://github.com/Ba…
ckoegel 8b7203b
add docstrings
ckoegel e56f441
Update test/integration/test_webrtc_api.py
ckoegel bf228d5
Merge branch 'feature/openapi-generator-sdk' into wertc-tests
ckoegel fa6fa29
Merge branch 'feature/openapi-generator-sdk' of https://github.com/Ba…
ckoegel fa481ea
use env_vars util
ckoegel de266de
Merge branch 'wertc-tests' of https://github.com/Bandwidth/python-sdk…
ckoegel 76feec2
fix gitignore
ckoegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,258 @@ | ||
| """ | ||
| Bandwidth | ||
|
|
||
| Bandwidth's Communication APIs # noqa: E501 | ||
|
|
||
| The version of the OpenAPI document: 1.0.0 | ||
| Contact: letstalk@bandwidth.com | ||
| Generated by: https://openapi-generator.tech | ||
| """ | ||
|
|
||
|
|
||
| from array import array | ||
| import unittest | ||
|
|
||
| import bandwidth | ||
| from hamcrest import * | ||
| from bandwidth.api import participants_api, sessions_api | ||
| from bandwidth.exceptions import NotFoundException, UnauthorizedException | ||
| from bandwidth.model.create_participant_request import CreateParticipantRequest | ||
| from bandwidth.model.create_participant_response import CreateParticipantResponse | ||
| from bandwidth.model.publish_permissions_enum import PublishPermissionsEnum | ||
| from bandwidth.model.device_api_version_enum import DeviceApiVersionEnum | ||
| from bandwidth.model.participant import Participant | ||
| from bandwidth.model.session import Session | ||
| from bandwidth.model.subscriptions import Subscriptions | ||
| from bandwidth.model.participant_subscription import ParticipantSubscription | ||
| from test.utils.env_variables import * | ||
|
|
||
|
|
||
| class TestSessionsApi(unittest.TestCase): | ||
ckoegel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """SessionsApi unit test stubs""" | ||
|
|
||
| def setUp(self): | ||
| # API Client | ||
| configuration = bandwidth.Configuration( | ||
| username = BW_USERNAME, | ||
| password = BW_PASSWORD | ||
| ) | ||
| api_client = bandwidth.ApiClient(configuration) | ||
| self.sessions_api_instance = sessions_api.SessionsApi(api_client) | ||
| self.participants_api_instance = participants_api.ParticipantsApi(api_client) | ||
| self.account_id = BW_ACCOUNT_ID | ||
|
|
||
| # Participant Properties | ||
| self.callback_url = 'https://example.com/callback' | ||
| self.publish_permissions = [ | ||
| PublishPermissionsEnum('AUDIO'), | ||
| PublishPermissionsEnum('VIDEO') | ||
| ] | ||
| self.participant_tag = 'python integration participant tag' | ||
| self.device_api_version = DeviceApiVersionEnum('V3') | ||
| self.participant_id = '' | ||
|
|
||
| # Participant Request | ||
| self.create_participant_request = CreateParticipantRequest( | ||
| callback_url=self.callback_url, | ||
| publish_permissions=self.publish_permissions, | ||
| tag=self.participant_tag, | ||
| device_api_version=self.device_api_version | ||
| ) | ||
|
|
||
| # Session Properties | ||
| self.session_tag = 'python integration session tag' | ||
| self.session_id = '' | ||
|
|
||
| # Session Request | ||
| self.session = Session( | ||
| tag=self.session_tag | ||
| ) | ||
|
|
||
| self.stream_aliases = ['python integration alias'] | ||
|
|
||
| def create_participant(self): | ||
| """Test creating participant | ||
brianluisgomez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| response = self.participants_api_instance.create_participant(self.account_id, create_participant_request=self.create_participant_request, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(200)) | ||
|
|
||
| assert_that(response[0], instance_of(CreateParticipantResponse)) | ||
| assert_that(response[0], has_properties( | ||
| 'participant', instance_of(Participant), | ||
| 'participant', has_properties( | ||
| 'device_api_version', self.device_api_version, | ||
| 'id', instance_of(str), | ||
| 'publish_permissions', contains_inanyorder( | ||
| PublishPermissionsEnum('AUDIO'), | ||
| PublishPermissionsEnum('VIDEO')), | ||
| 'tag', self.participant_tag | ||
| ), | ||
| 'token', instance_of(str) | ||
| )) | ||
|
|
||
| self.participant_id = response[0].participant.id | ||
|
|
||
| def delete_participant(self): | ||
| """Test deleting participant | ||
| """ | ||
| response = self.participants_api_instance.delete_participant(self.account_id, self.participant_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(204)) | ||
|
|
||
| def get_participant(self): | ||
| """Test getting participant | ||
| """ | ||
| response = self.participants_api_instance.get_participant(self.account_id, self.participant_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(200)) | ||
| assert_that(response[0], instance_of(Participant)) | ||
| assert_that(response[0], has_properties( | ||
| 'device_api_version', self.device_api_version, | ||
| 'id', self.participant_id, | ||
| 'publish_permissions', contains_inanyorder( | ||
| PublishPermissionsEnum('AUDIO'), | ||
| PublishPermissionsEnum('VIDEO')), | ||
| 'sessions', [self.session_id], | ||
| 'subscriptions', has_properties( | ||
| 'participants', instance_of(list) | ||
| ), | ||
| 'tag', self.participant_tag | ||
| )) | ||
|
|
||
| def add_participant_to_session(self): | ||
| """Test adding participant to session | ||
| """ | ||
| response = self.sessions_api_instance.add_participant_to_session(self.account_id, self.session_id, self.participant_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(204)) | ||
|
|
||
|
|
||
| def create_session(self): | ||
| """Test creating session | ||
| """ | ||
| response = self.sessions_api_instance.create_session(self.account_id, session=self.session, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(200)) | ||
|
|
||
| assert_that(response[0], instance_of(Session)) | ||
| assert_that(response[0], has_properties( | ||
| 'id', instance_of(str), | ||
| 'tag', self.session_tag, | ||
| 'participant_ids', instance_of(array), | ||
| 'participant_ids', empty() | ||
| )) | ||
|
|
||
| self.session_id = response[0].id | ||
|
|
||
| def delete_session(self): | ||
| """Test deleting session | ||
| """ | ||
| response = self.sessions_api_instance.delete_session(self.account_id, self.session_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(204)) | ||
|
|
||
| def get_participant_subscriptions(self): | ||
| """Test getting participant subscriptions | ||
| """ | ||
| response = self.sessions_api_instance.get_participant_subscriptions(self.account_id, self.session_id, self.participant_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(200)) | ||
|
|
||
| assert_that(response[0], has_properties( | ||
| 'participants', instance_of(list), | ||
| 'session_id', self.session_id | ||
| )) | ||
| assert_that(response[0].participants[0], instance_of(ParticipantSubscription)) | ||
| assert_that(response[0].participants[0], has_properties( | ||
| 'participant_id', self.participant_id, | ||
| 'stream_aliases', self.stream_aliases | ||
| )) | ||
|
|
||
| def get_session(self): | ||
| """Test getting session | ||
| """ | ||
| response = self.sessions_api_instance.get_session(self.account_id, self.session_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(200)) | ||
|
|
||
| assert_that(response[0], has_properties( | ||
| 'id', self.session_id, | ||
| 'tag', self.session_tag, | ||
| 'participant_ids', contains_exactly(self.participant_id) | ||
| )) | ||
|
|
||
| def list_session_participants(self): | ||
| """Test listing session participants | ||
| """ | ||
| response = self.sessions_api_instance.list_session_participants(self.account_id, self.session_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(200)) | ||
|
|
||
| assert_that(response[0], instance_of(list)) | ||
| assert_that(response[0][0], instance_of(Participant)) | ||
| assert_that(response[0][0], has_properties( | ||
| 'device_api_version', self.device_api_version, | ||
| 'id', self.participant_id, | ||
| 'publish_permissions', contains_inanyorder( | ||
| PublishPermissionsEnum('AUDIO'), | ||
| PublishPermissionsEnum('VIDEO')), | ||
| 'sessions', [self.session_id], | ||
| 'tag', self.participant_tag | ||
| )) | ||
|
|
||
| def remove_participant_from_session(self): | ||
| """Test removing participant from session | ||
| """ | ||
| response = self.sessions_api_instance.remove_participant_from_session(self.account_id, self.session_id, self.participant_id, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(204)) | ||
|
|
||
| def update_participant_subscriptions(self): | ||
| """Test updating participant subscriptions | ||
| """ | ||
| subscriptions = Subscriptions( | ||
| session_id=self.session_id, | ||
| participants=[ | ||
| ParticipantSubscription( | ||
| participant_id=self.participant_id, | ||
| stream_aliases=self.stream_aliases, | ||
| ) | ||
| ], | ||
| ) | ||
|
|
||
| response = self.sessions_api_instance.update_participant_subscriptions(self.account_id, self.session_id, self.participant_id, subscriptions=subscriptions, _return_http_data_only=False) | ||
|
|
||
| assert_that(response[1], equal_to(204)) | ||
|
|
||
| def get_participant_unauthorized(self): | ||
| """Test getting participant with unauthorized API client | ||
| """ | ||
| unauthorized_api_client = bandwidth.ApiClient() | ||
| unauthorized_participants_api_instance = participants_api.ParticipantsApi(unauthorized_api_client) | ||
|
|
||
| assert_that(calling(unauthorized_participants_api_instance.get_participant).with_args( | ||
| self.account_id, self.participant_id, _return_http_data_only=False)), raises(UnauthorizedException) | ||
|
|
||
| def get_participant_not_found(self): | ||
| """Test getting nonexistent participant | ||
| """ | ||
| assert_that(calling(self.participants_api_instance.get_participant).with_args( | ||
| self.account_id, self.participant_id)), raises(NotFoundException) | ||
|
|
||
| def _steps(self) -> None: | ||
| call_order = ['create_participant', 'create_session', 'add_participant_to_session', | ||
| 'get_session', 'list_session_participants', 'update_participant_subscriptions', | ||
| 'get_participant_subscriptions', 'get_participant', 'remove_participant_from_session', | ||
| 'delete_session', 'delete_participant', 'get_participant_unauthorized', 'get_participant_not_found'] | ||
| for name in call_order: | ||
| yield name, getattr(self, name) | ||
|
|
||
| def test_steps(self) -> None: | ||
| """Test each function from _steps.call_order in specified order | ||
| """ | ||
| for name, step in self._steps(): | ||
| step() | ||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.