本文整理匯總了Python中opentok.OpenTok.force_disconnect方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenTok.force_disconnect方法的具體用法?Python OpenTok.force_disconnect怎麽用?Python OpenTok.force_disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類opentok.OpenTok
的用法示例。
在下文中一共展示了OpenTok.force_disconnect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: OpenTokForceDisconnectTest
# 需要導入模塊: from opentok import OpenTok [as 別名]
# 或者: from opentok.OpenTok import force_disconnect [as 別名]
class OpenTokForceDisconnectTest(unittest.TestCase):
"""" Class that contains test for force disconnect functionality """
def setUp(self):
self.api_key = u('123456')
self.api_secret = u('1234567890abcdef1234567890abcdef1234567890')
self.opentok = OpenTok(self.api_key, self.api_secret)
self.session_id = u('SESSIONID')
self.connection_id = u('CONNECTIONID')
@httpretty.activate
def test_force_disconnect(self):
""" Method to test force disconnect functionality using an OpenTok instance """
httpretty.register_uri(
httpretty.DELETE,
u('https://api.opentok.com/v2/project/{0}/session/{1}/connection/{2}').format(
self.api_key,
self.session_id,
self.connection_id
),
status=204,
content_type=u('application/json')
)
self.opentok.force_disconnect(self.session_id, self.connection_id)
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json')))
@httpretty.activate
def test_throws_force_disconnect_exception(self):
""" This method should throw a ForceDisconnectError """
httpretty.register_uri(
httpretty.DELETE,
u('https://api.opentok.com/v2/project/{0}/session/{1}/connection/{2}').format(
self.api_key,
self.session_id,
self.connection_id
),
status=400,
content_type=u('application/json')
)
self.assertRaises(
ForceDisconnectError,
self.opentok.force_disconnect,
self.session_id,
self.connection_id
)
@httpretty.activate
def test_throws_auth_exception(self):
""" This method should throw an AuthError """
httpretty.register_uri(
httpretty.DELETE,
u('https://api.opentok.com/v2/project/{0}/session/{1}/connection/{2}').format(
self.api_key,
self.session_id,
self.connection_id
),
status=403,
content_type=u('application/json')
)
self.assertRaises(
AuthError,
self.opentok.force_disconnect,
self.session_id,
self.connection_id
)