def test_s3store(s3fs): tmp_dir = '/tmp/prov_s3store' shutil.rmtree(tmp_dir, ignore_errors=True) basepath = "bucket/prov_test" store = bs.S3Store(tmp_dir, basepath, s3fs=s3fs, delete=True) key = sha1.example() obj = builtin_data.example() assert_store_basic_ops(store, key, obj)
def test_chained_storage_with_disk_and_s3_sharing_cachedir(s3fs): tmp_dir = '/tmp/prov_shared_store' shutil.rmtree(tmp_dir, ignore_errors=True) mem_store = bs.MemoryStore(read=True, write=True, delete=True) disk_store = bs.DiskStore(tmp_dir, read=True, write=True, delete=True) s3_store = bs.S3Store( tmp_dir, s3fs=s3fs, basepath='bucket/prov_test', read=True, write=True, delete=True, always_check_remote=True, ) stores = [mem_store, disk_store, s3_store] chained_store = bs.ChainedStore(stores) key = 'foobar' data = {'a': 1, 'b': 2} for store in stores: assert key not in store assert key not in store chained_store.put(key, data) assert key in store for store in stores: assert key in store assert store.get(key) == data assert store[key] == data store.delete(key) assert key not in store with pytest.raises(KeyError): store.delete(key) with pytest.raises(KeyError): store.get(key)