Example #1
0
    def test_get_attachment(self, rget):
        sample_captions = u"""
            1
            00:00:00,000 --> 00:00:10,500
            Rebecca: This is a sample first line with a speaker

            2
            0:00:10,500 --> 00:00:20,761
            ^and this is the second line with the same speaker,
        """.strip()

        def mocked_get(url, headers):
            ok_(settings.REV_BASE_URL in url)
            ok_(settings.REV_CLIENT_API_KEY in headers['Authorization'])
            ok_(settings.REV_USER_API_KEY in headers['Authorization'])
            return Response(sample_captions,
                            headers={
                                'Content-Disposition':
                                'attachment; filename=sample.srt',
                                'Content-Type': 'text/x-rev-caption',
                            })

        rget.side_effect = mocked_get
        result = rev.get_attachment('fyKpNl7bAgAAAAAA')
        eq_(result.text, sample_captions)
Example #2
0
def event_rev_orders_download(request, event_id, id, attachment_id):
    rev_order = get_object_or_404(RevOrder, event__id=event_id, id=id)
    for attachment in rev_order.get_order()['attachments']:
        if attachment['id'] == attachment_id:
            response_attachment = rev.get_attachment(attachment['id'])
            response = http.HttpResponse()
            response['Content-Type'] = (
                response_attachment.headers['Content-Type'])
            response['Content-Disposition'] = (
                response_attachment.headers['Content-Disposition'])
            response.write(response_attachment.text)
            return response
    return http.HttpResponseBadRequest(attachment_id)
Example #3
0
def event_rev_orders_download(request, event_id, id, attachment_id):
    rev_order = get_object_or_404(RevOrder, event__id=event_id, id=id)
    for attachment in rev_order.get_order()['attachments']:
        if attachment['id'] == attachment_id:
            response_attachment = rev.get_attachment(attachment['id'])
            response = http.HttpResponse()
            response['Content-Type'] = (
                response_attachment.headers['Content-Type']
            )
            response['Content-Disposition'] = (
                response_attachment.headers['Content-Disposition']
            )
            response.write(response_attachment.text)
            return response
    return http.HttpResponseBadRequest(attachment_id)
Example #4
0
    def test_get_attachment(self, rget):
        sample_captions = u"""
            1
            00:00:00,000 --> 00:00:10,500
            Rebecca: This is a sample first line with a speaker

            2
            0:00:10,500 --> 00:00:20,761
            ^and this is the second line with the same speaker,
        """.strip()

        def mocked_get(url, headers):
            ok_(settings.REV_BASE_URL in url)
            ok_(settings.REV_CLIENT_API_KEY in headers['Authorization'])
            ok_(settings.REV_USER_API_KEY in headers['Authorization'])
            return Response(sample_captions, headers={
                'Content-Disposition': 'attachment; filename=sample.srt',
                'Content-Type': 'text/x-rev-caption',
            })

        rget.side_effect = mocked_get
        result = rev.get_attachment('fyKpNl7bAgAAAAAA')
        eq_(result.text, sample_captions)