def test_get_into_stream(self, store, key, value): store.put(key, value) output = BytesIO() store.get_file(key, output) assert output.getvalue() == value
def test_get_into_stream(self, store, key, value): store.put(key, value) output = BytesIO() store.get_file(key, output) assert output.getvalue() == value
def test_put_file_set_default(self, store, key, value, small_ttl): store.default_ttl_secs = small_ttl store.put_file(key, BytesIO(value)) time.sleep(small_ttl + TTL_MARGIN) with pytest.raises(KeyError): store.get(key)
def test_manipulated_input_full_read(self, secret_key, value, bad_datas, hashfunc): for bad_data in bad_datas: reader = _HMACFileReader(hmac.HMAC(secret_key, None, hashfunc), BytesIO(bad_data)) with pytest.raises(VerificationException): reader.read()
def test_storage_class_putfile(self, store, prefix, key, value, storage_class, bucket): store.put_file(key, BytesIO(value)) keyname = prefix + key if storage_class != 'STANDARD': pytest.xfail('boto does not support checking the storage class?') assert bucket.lookup(keyname).storage_class == storage_class
def test_manipulated_input_incremental_read(self, secret_key, bad_datas, hashfunc): for bad_data in bad_datas: reader = _HMACFileReader(hmac.HMAC(secret_key, None, hashfunc), BytesIO(bad_data)) with pytest.raises(VerificationException): bitesize = 100 while True: if len(reader.read(bitesize)) != bitesize: break
def test_file_permission_on_new_file_have_correct_value( self, store, perms, value): src = BytesIO(value) key = store.put_file(u'test123', src) parts = urlparse(store.url_for(key)) path = parts.path mode = os.stat(path).st_mode mask = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) assert mode & mask == perms
def test_put_file_sets_prefix(self, store, prefix, key, value): full_key = prefix + key key == store.put_file(key, BytesIO(value)) assert store._dstore.get(full_key) == value
def test_put_file_return_value(self, store, key, value): assert key == store.put_file(key, BytesIO(value))
def test_open_incremental_read(self, store, key, long_value): store.put_file(key, BytesIO(long_value)) ok = store.open(key) assert long_value[:3] == ok.read(3) assert long_value[3:5] == ok.read(2) assert long_value[5:8] == ok.read(3)
def test_key_error_on_nonexistant_get_file(self, store, key): with pytest.raises(KeyError): store.get_file(key, BytesIO())
def test_put_file_obj(self, key, value, hmacstore): hmacstore.put_file(key, BytesIO(value)) assert hmacstore.get(key) == value
def test_store_and_open(self, store, key, value): store.put_file(key, BytesIO(value)) assert store.open(key).read() == value
def test_store_and_retrieve_overwrite(self, store, key, value, value2): store.put_file(key, BytesIO(value)) assert store.get(key) == value store.put(key, value2) assert store.get(key) == value2
def test_put_file_with_ttl_argument(self, store, key, value, small_ttl): store.put_file(key, BytesIO(value), small_ttl) time.sleep(small_ttl + TTL_MARGIN) with pytest.raises(KeyError): store.get(key)
def test_store_and_retrieve_filelike(self, store, key, value): store.put_file(key, BytesIO(value)) assert store.get(key) == value
def test_put_file_returns_correct_key(self, store, prefix, key, value): assert key == store.put_file(key, BytesIO(value))
def test_get_file_obj(self, key, value, hmacstore): hmacstore.put(key, value) b = BytesIO() hmacstore.get_file(key, b) assert b.getvalue() == value
def test_input_too_short(self, secret_key, hashfunc): with pytest.raises(VerificationException): _HMACFileReader(hmac.HMAC(secret_key, None, hashfunc), BytesIO(b('a')))
def create_reader(self, stored_blob, secret_key, hashfunc): return lambda: _HMACFileReader(hmac.HMAC(secret_key, None, hashfunc), BytesIO(stored_blob))