def test_delete_archive(self):
        archive_id = u('ARCHIVEID')
        archive = Archive(
            self.opentok, {
                u('createdAt'): 1395183243556,
                u('duration'): 0,
                u('id'): archive_id,
                u('name'): u(''),
                u('partnerId'): 123456,
                u('reason'): u(''),
                u('sessionId'): u('SESSIONID'),
                u('size'): 0,
                u('status'): u('available'),
                u('hasAudio'): True,
                u('hasVideo'): True,
                u('outputMode'): OutputModes.composed.value,
                u('url'): None,
            })
        httpretty.register_uri(
            httpretty.DELETE,
            u('https://api.opentok.com/v2/partner/{0}/archive/{1}').format(
                self.api_key, archive_id),
            body=u(''),
            status=204)

        archive.delete()

        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'))
Ejemplo n.º 2
0
    def test_delete_archive_1(self):
        self.httpretty_enable()
        archive_id = u('ARCHIVEID')
        archive = Archive(self.opentok, {
            u('createdAt'): 1395183243556,
            u('duration'): 0,
            u('id'): archive_id,
            u('name'): u(''),
            u('partnerId'): 123456,
            u('reason'): u(''),
            u('sessionId'): u('SESSIONID'),
            u('size'): 0,
            u('status'): u('available'),
            u('url'): None,
        })
        httpretty.register_uri(httpretty.DELETE, u('https://api.opentok.com/v2/partner/{0}/archive/{1}').format(self.api_key, archive_id),
                               body=u(''),
                               status=204)

        archive.delete()

        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'))
        self.httpretty_disable()
    def test_delete_archive(self):
        archive_id = u('ARCHIVEID')
        archive = Archive(self.opentok, {
            u('createdAt'): 1395183243556,
            u('duration'): 0,
            u('id'): archive_id,
            u('name'): u(''),
            u('partnerId'): 123456,
            u('reason'): u(''),
            u('sessionId'): u('SESSIONID'),
            u('size'): 0,
            u('status'): u('available'),
            u('hasAudio'): True,
            u('hasVideo'): True,
            u('outputMode'): OutputModes.composed.value,
            u('url'): None,
        })
        httpretty.register_uri(httpretty.DELETE, u('https://api.opentok.com/v2/partner/{0}/archive/{1}').format(self.api_key, archive_id),
                               body=u(''),
                               status=204)

        archive.delete()

        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')))
Ejemplo n.º 4
0
    def test_stop_archive(self):
        archive_id = u('ARCHIVEID')
        archive = Archive(self.opentok, {
            u('createdAt'): 1395183243556,
            u('duration'): 0,
            u('id'): archive_id,
            u('name'): u(''),
            u('partnerId'): 123456,
            u('reason'): u(''),
            u('sessionId'): u('SESSIONID'),
            u('size'): 0,
            u('status'): u('started'),
            u('hasAudio'): True,
            u('hasVideo'): True,
            u('outputMode'): OutputModes.composed.value,
            u('url'): None,
        })
        httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/v2/partner/{0}/archive/{1}/stop').format(self.api_key, archive_id),
                               body=textwrap.dedent(u("""\
                                       {
                                          "createdAt" : 1395183243556,
                                          "duration" : 0,
                                          "id" : "ARCHIVEID",
                                          "name" : "",
                                          "partnerId" : 123456,
                                          "reason" : "",
                                          "sessionId" : "SESSIONID",
                                          "size" : 0,
                                          "status" : "stopped",
                                          "hasAudio": true,
                                          "hasVideo": false,
                                          "outputMode": "composed",
                                          "url" : null
                                        }""")),
                               status=200,
                               content_type=u('application/json'))

        archive.stop()

        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')))
        expect(archive).to(be_an(Archive))
        expect(archive).to(have_property(u('id'), archive_id))
        expect(archive).to(have_property(u('name'), u('')))
        expect(archive).to(have_property(u('status'), u('stopped')))
        expect(archive).to(have_property(u('session_id'), u('SESSIONID')))
        expect(archive).to(have_property(u('partner_id'), 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'), created_at))
        expect(archive).to(have_property(u('size'), 0))
        expect(archive).to(have_property(u('duration'), 0))
        expect(archive).to(have_property(u('has_audio'), True))
        expect(archive).to(have_property(u('has_video'), False))
        expect(archive).to(have_property(u('output_mode'), OutputModes.composed))
        expect(archive).to(have_property(u('url'), None))
Ejemplo n.º 5
0
    def test_stop_archive_1(self):
        self.httpretty_enable()
        archive_id = u('ARCHIVEID')
        archive = Archive(self.opentok, {
            u('createdAt'): 1395183243556,
            u('duration'): 0,
            u('id'): archive_id,
            u('name'): u(''),
            u('partnerId'): 123456,
            u('reason'): u(''),
            u('sessionId'): u('SESSIONID'),
            u('size'): 0,
            u('status'): u('started'),
            u('url'): None,
        })
        httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/v2/partner/{0}/archive/{1}/stop').format(self.api_key, archive_id),
                               body=textwrap.dedent(u("""\
                                       {
                                          "createdAt" : 1395183243556,
                                          "duration" : 0,
                                          "id" : "ARCHIVEID",
                                          "name" : "",
                                          "partnerId" : 123456,
                                          "reason" : "",
                                          "sessionId" : "SESSIONID",
                                          "size" : 0,
                                          "status" : "stopped",
                                          "url" : null
                                        }""")),
                               status=200,
                               content_type=u('application/json'))

        archive.stop()

        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'))
        expect(archive).to.be.an(Archive)
        expect(archive).to.have.property(u('id')).being.equal(archive_id)
        expect(archive).to.have.property(u('name')).being.equal(u(''))
        expect(archive).to.have.property(u('status')).being.equal(u('stopped'))
        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('url')).being.equal(None)
        self.httpretty_disable()
Ejemplo n.º 6
0
    def test_delete_archive(self):
        archive_id = u("ARCHIVEID")
        archive = Archive(
            self.opentok,
            {
                u("createdAt"): 1395183243556,
                u("duration"): 0,
                u("id"): archive_id,
                u("name"): u(""),
                u("partnerId"): 123456,
                u("reason"): u(""),
                u("sessionId"): u("SESSIONID"),
                u("size"): 0,
                u("status"): u("available"),
                u("hasAudio"): True,
                u("hasVideo"): True,
                u("outputMode"): OutputModes.composed.value,
                u("url"): None,
            },
        )
        httpretty.register_uri(
            httpretty.DELETE,
            u("https://api.opentok.com/v2/project/{0}/archive/{1}").format(
                self.api_key, archive_id
            ),
            body=u(""),
            status=204,
        )

        archive.delete()

        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"))
        )