Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions bandwidth.json
Original file line number Diff line number Diff line change
Expand Up @@ -4429,9 +4429,6 @@
"subscriptions": {
"type": "object",
"readOnly": true,
"required": [
"sessionId"
],
"properties": {
"sessionId": {
"type": "string",
Expand Down
14 changes: 4 additions & 10 deletions bandwidth/model/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,9 @@ def discriminator():

@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(cls, session_id, *args, **kwargs): # noqa: E501
def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
"""Subscriptions - a model defined in OpenAPI

Args:
session_id (str): Session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object.

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
Expand Down Expand Up @@ -146,6 +143,7 @@ def _from_openapi_data(cls, session_id, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
session_id (str): Session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object.. [optional] # noqa: E501
participants ([ParticipantSubscription]): (optional) A list of participants in the session that will be subscribed to. Returns empty if used during the creation of a Participant. . [optional] # noqa: E501
"""

Expand Down Expand Up @@ -178,7 +176,6 @@ def _from_openapi_data(cls, session_id, *args, **kwargs): # noqa: E501
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.session_id = session_id
for var_name, var_value in kwargs.items():
if var_name not in self.attribute_map and \
self._configuration is not None and \
Expand All @@ -199,12 +196,9 @@ def _from_openapi_data(cls, session_id, *args, **kwargs): # noqa: E501
])

@convert_js_args_to_python_args
def __init__(self, session_id, *args, **kwargs): # noqa: E501
def __init__(self, *args, **kwargs): # noqa: E501
"""Subscriptions - a model defined in OpenAPI

Args:
session_id (str): Session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object.

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
Expand Down Expand Up @@ -236,6 +230,7 @@ def __init__(self, session_id, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
session_id (str): Session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object.. [optional] # noqa: E501
participants ([ParticipantSubscription]): (optional) A list of participants in the session that will be subscribed to. Returns empty if used during the creation of a Participant. . [optional] # noqa: E501
"""

Expand Down Expand Up @@ -266,7 +261,6 @@ def __init__(self, session_id, *args, **kwargs): # noqa: E501
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.session_id = session_id
for var_name, var_value in kwargs.items():
if var_name not in self.attribute_map and \
self._configuration is not None and \
Expand Down
2 changes: 1 addition & 1 deletion docs/Subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**session_id** | **str** | Session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object. |
**session_id** | **str** | Session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object. | [optional]
**participants** | [**[ParticipantSubscription]**](ParticipantSubscription.md) | (optional) A list of participants in the session that will be subscribed to. Returns empty if used during the creation of a Participant. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

Expand Down
258 changes: 258 additions & 0 deletions test/integration/test_webrtc_api.py
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):
"""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
"""
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()