本文整理汇总了Python中opentok.OpenTok.start_archive方法的典型用法代码示例。如果您正苦于以下问题:Python OpenTok.start_archive方法的具体用法?Python OpenTok.start_archive怎么用?Python OpenTok.start_archive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opentok.OpenTok
的用法示例。
在下文中一共展示了OpenTok.start_archive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OpenTokArchiveApiTest
# 需要导入模块: from opentok import OpenTok [as 别名]
# 或者: from opentok.OpenTok import start_archive [as 别名]
class OpenTokArchiveApiTest(unittest.TestCase):
def setUp(self):
self.api_key = u('123456')
self.api_secret = u('1234567890abcdef1234567890abcdef1234567890')
self.session_id = u('SESSIONID')
self.opentok = OpenTok(self.api_key, self.api_secret)
@httpretty.activate
def test_start_archive(self):
httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/v2/partner/{0}/archive').format(self.api_key),
body=textwrap.dedent(u("""\
{
"createdAt" : 1395183243556,
"duration" : 0,
"id" : "30b3ebf1-ba36-4f5b-8def-6f70d9986fe9",
"name" : "",
"partnerId" : 123456,
"reason" : "",
"sessionId" : "SESSIONID",
"size" : 0,
"status" : "started",
"hasAudio": true,
"hasVideo": true,
"outputMode": "composed",
"url" : null
}""")),
status=200,
content_type=u('application/json'))
archive = self.opentok.start_archive(self.session_id)
expect(httpretty.last_request().headers[u('x-tb-partner-auth')]).to.equal(self.api_key+u(':')+self.api_secret)
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'))
# non-deterministic json encoding. have to decode to test it properly
if PY2:
body = json.loads(httpretty.last_request().body)
if PY3:
body = json.loads(httpretty.last_request().body.decode('utf-8'))
expect(body).to.have.key(u('name')).being.equal(None)
expect(body).to.have.key(u('sessionId')).being.equal(u('SESSIONID'))
expect(archive).to.be.an(Archive)
expect(archive).to.have.property(u('id')).being.equal(u('30b3ebf1-ba36-4f5b-8def-6f70d9986fe9'))
expect(archive).to.have.property(u('name')).being.equal(u(''))
expect(archive).to.have.property(u('status')).being.equal(u('started'))
expect(archive).to.have.property(u('session_id')).being.equal(u('SESSIONID'))
expect(archive).to.have.property(u('partner_id')).being.equal(123456)
if PY2:
created_at = datetime.datetime.fromtimestamp(1395183243, pytz.UTC)
if PY3:
created_at = datetime.datetime.fromtimestamp(1395183243, datetime.timezone.utc)
expect(archive).to.have.property(u('created_at')).being.equal(created_at)
expect(archive).to.have.property(u('size')).being.equal(0)
expect(archive).to.have.property(u('duration')).being.equal(0)
expect(archive).to.have.property(u('has_audio')).being.equal(True)
expect(archive).to.have.property(u('has_video')).being.equal(True)
expect(archive).to.have.property(u('url')).being.equal(None)
@httpretty.activate
def test_start_archive_with_name(self):
httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/v2/partner/{0}/archive').format(self.api_key),
body=textwrap.dedent(u("""\
{
"createdAt" : 1395183243556,
"duration" : 0,
"id" : "30b3ebf1-ba36-4f5b-8def-6f70d9986fe9",
"name" : "ARCHIVE NAME",
"partnerId" : 123456,
"reason" : "",
"sessionId" : "SESSIONID",
"size" : 0,
"status" : "started",
"hasAudio": true,
"hasVideo": true,
"outputMode": "composed",
"url" : null
}""")),
status=200,
content_type=u('application/json'))
archive = self.opentok.start_archive(self.session_id, name=u('ARCHIVE NAME'))
expect(httpretty.last_request().headers[u('x-tb-partner-auth')]).to.equal(self.api_key+u(':')+self.api_secret)
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'))
# non-deterministic json encoding. have to decode to test it properly
if PY2:
body = json.loads(httpretty.last_request().body)
if PY3:
body = json.loads(httpretty.last_request().body.decode('utf-8'))
expect(body).to.have.key(u('sessionId')).being.equal(u('SESSIONID'))
expect(body).to.have.key(u('name')).being.equal(u('ARCHIVE NAME'))
expect(archive).to.be.an(Archive)
expect(archive).to.have.property(u('id')).being.equal(u('30b3ebf1-ba36-4f5b-8def-6f70d9986fe9'))
expect(archive).to.have.property(u('name')).being.equal(u('ARCHIVE NAME'))
expect(archive).to.have.property(u('status')).being.equal(u('started'))
expect(archive).to.have.property(u('session_id')).being.equal(u('SESSIONID'))
expect(archive).to.have.property(u('partner_id')).being.equal(123456)
if PY2:
created_at = datetime.datetime.fromtimestamp(1395183243, pytz.UTC)
#.........这里部分代码省略.........