Ejemplo n.º 1
0
    def test_expose_blob_download(self):
        ref = expose_blob_download(
            self.identifier,
            expiry=60,
            content_disposition='text/xml',
        )
        self.db.put(BytesIO(b'content'), meta=new_meta(key=ref.download_id))

        response = BlobDownload.get(ref.download_id).toHttpResponse()
        self.assertEqual(next(response.streaming_content), b'content')
Ejemplo n.º 2
0
    def test_expose_blob_download_with_legacy_download_id(self):
        self.db.put(BytesIO(b'legacy-blob'), self.identifier)

        ref = BlobDownload(
            self.identifier,
            mimetype='text/plain',
            content_disposition='text/xml',
        )
        ref.download_id = uuid4().hex  # old download id format
        ref.save(60)

        response = BlobDownload.get(ref.download_id).toHttpResponse()
        self.assertEqual(next(response.streaming_content), 'legacy-blob')
Ejemplo n.º 3
0
    def test_expose_blob_download(self):
        content_disposition = 'text/xml'
        download_id = 'abc123'

        self.db.put(StringIO(u'content'), self.identifier)

        expose_blob_download(self.identifier,
                             content_disposition=content_disposition,
                             download_id=download_id)

        download = BlobDownload.get(download_id)

        self.assertIsNotNone(download)

        response = download.toHttpResponse()
        self.assertEqual(next(response.streaming_content), u'content')