#! /usr/bin/env python import os import time import s3po import unittest from cStringIO import StringIO # Logging stuff import logging from s3po import logger logger.setLevel(logging.DEBUG) class TestList(unittest.TestCase): def setUp(self): logger.info('Setting up') self.payload = '0' * 1024 self.nkeys = 4 self.bucket = 'freshscape' self.prefix = 'test/key' self.keys = [self.prefix + repr(i) for i in range(self.nkeys)] self.connection = s3po.Connection( 'access_id', 'secret_key', async=False) def tearDown(self): logger.info('Tearing down...') try: b = self.connection.conn.get_bucket(self.bucket) for key in self.keys:
#! /usr/bin/env python import os import time import unittest import s3po.util from cStringIO import StringIO # Logging stuff import logging from s3po import logger logger.setLevel(logging.CRITICAL) class TestCompress(unittest.TestCase): def setUp(self): self.data = 'Hello, how are all you all today?' * 1024 self.stringio = StringIO(self.data) def test_zlib(self): # First, compress, and make sure that it's not the same as original compressed = StringIO() s3po.util.compressToFile(self.stringio, compressed, 'zlib') self.assertNotEqual(self.data, compressed.getvalue(), 'Compressed content same as input') # Now, decompress, make sure it equals the original decompressed = StringIO() s3po.util.decompressToFile(compressed, decompressed, 'zlib') self.assertEqual(self.data, decompressed.getvalue(), 'Decompressed content does not equal original.')