def iter_test(self): self.conn.sync() key = BotoKey(self.boto_bucket) key.key = 'list' key.set_contents_from_string('list') bucket = self.conn.get_bucket(self.name) assert 'list' not in [key.name for key in bucket]
def get_unsynced_key_force_test(self): self.conn.sync() boto_key = BotoKey(self.boto_bucket) boto_key.name = 'get_key' boto_key.set_contents_from_string('get_key') bucket = self.conn.get_bucket(self.name) key = bucket.get_key('get_key', force=True) assert key is not None
def get_all_force_test(self): self.conn.sync() boto_key = BotoKey(self.boto_bucket) boto_key.name = 'get_all' boto_key.set_contents_from_string('get_all') bucket = self.conn.get_bucket(self.name) assert 'get_all' in [ key.name for key in bucket.get_all_keys(force=True) ]
def list_force_test(self): self.conn.sync() key = BotoKey(self.boto_bucket) key.key = 'list' key.set_contents_from_string('list') bucket = self.conn.get_bucket(self.name) keys = list(bucket.list(force=True)) assert 'list' in [key.name for key in keys] assert hashlib.md5('list').hexdigest() in [key.md5 for key in keys]
def setUp(self): MimicDB(namespace='tests') self.conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) self.boto_conn = BotoS3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) self.name = 'mimicdb-tests-' + random_string() self.boto_bucket = self.boto_conn.create_bucket(self.name) key = BotoKey(self.boto_bucket) key.key = 'upload' key.set_contents_from_string('upload')
def sync_bucket_clear_test(self): self.conn.sync() key = BotoKey(self.boto_bucket) key.key = 'upload' key.set_contents_from_string('sync_clear') self.conn.sync(self.name) meta = mimicdb.backend.hgetall(tpl.key % (self.name, 'upload')) assert int(meta['size']) == len('sync_clear') assert meta['md5'] == hashlib.md5('sync_clear').hexdigest()
def bucket_sync_test(self): self.conn.sync() boto_key = BotoKey(self.boto_bucket) boto_key.name = 'sync' boto_key.set_contents_from_string('sync') bucket = self.conn.get_bucket(self.name) bucket.sync() key = bucket.get_key('sync') assert key.size == len('sync') assert key.md5 == hashlib.md5('sync').hexdigest()
def track_download_meta_init_test(self): self.conn.sync() bucket = self.conn.get_bucket(self.name) key = BotoKey(self.boto_bucket) key.key = 'download' key.set_contents_from_string('download') key = Key(bucket, 'download') key.get_contents_as_string() meta = mimicdb.backend.hgetall(tpl.key % (self.name, 'download')) assert int(meta['size']) == len('download') assert meta['md5'] == hashlib.md5('download').hexdigest()