Exemplo n.º 1
0
    def setUp(self):
        super(GSStorageTest, self).setUp()

        self.storage = AppEngineStorage(storage_service=CLOUD_STORAGE_SERVICE, cloud_storage_bucket='test_bucket')

        file_name = '/test_bucket/file.test'
        with cloudstorage.open(file_name, 'w') as f:
            f.write('abcdef')

        self.file_key = '/gs' + file_name
        self.test_file_info = self.file_info(self.file_key)
Exemplo n.º 2
0
    def setUp(self):
        super(BlobstoreStorageTest, self).setUp()

        self.storage = AppEngineStorage(storage_service=BLOBSTORE_SERVICE)

        file_name = files.blobstore.create()

        with files.open(file_name, 'a') as f:
            f.write('abcdef')

        files.finalize(file_name)

        self.blob_key = files.blobstore.get_blob_key(file_name)
        self.file_key = str(self.blob_key)
        self.test_file_info = self.file_info(self.file_key)
Exemplo n.º 3
0
class GSStorageTest(AppEngineStorageBaseTest, TestCase):
    def setUp(self):
        super(GSStorageTest, self).setUp()

        self.storage = AppEngineStorage(storage_service=CLOUD_STORAGE_SERVICE, cloud_storage_bucket='test_bucket')

        file_name = '/test_bucket/file.test'
        with cloudstorage.open(file_name, 'w') as f:
            f.write('abcdef')

        self.file_key = '/gs' + file_name
        self.test_file_info = self.file_info(self.file_key)

    def file_info(self, name):
        return CloudStorageInfo(name)

    def test_file_url(self):
        url = self.storage.url(self.file_key)
        self.assertTrue(url.startswith('/_ah/img/encoded_gs_file:'))
Exemplo n.º 4
0
class BlobstoreStorageTest(AppEngineStorageBaseTest, TestCase):
    def setUp(self):
        super(BlobstoreStorageTest, self).setUp()

        self.storage = AppEngineStorage(storage_service=BLOBSTORE_SERVICE)

        file_name = files.blobstore.create()

        with files.open(file_name, 'a') as f:
            f.write('abcdef')

        files.finalize(file_name)

        self.blob_key = files.blobstore.get_blob_key(file_name)
        self.file_key = str(self.blob_key)
        self.test_file_info = self.file_info(self.file_key)

    def file_info(self, name):
        key = BlobKey(name.split('/', 1)[0])
        return BlobInfo(key)

    def test_file_url(self):
        url = self.storage.url(self.file_key)
        self.assertEqual(url, '/_ah/img/%s' % self.file_key)