本文整理汇总了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
)