fake-py-cloudpathlib-storage
cloudpathlib storage for fake.py.
fake-py-cloudpathlib-storage is a cloudpathlib storage integration for fake.py - a standalone, portable library designed for generating various random data types for testing.
It is a sibling of (and a drop-in-minded successor to) fake-py-pathy-storage, built on the actively maintained cloudpathlib.
Features
Cloud storages integration includes support for AWS S3, Google Cloud Storage and Azure Blob Storage.
Local file system storage with the same interface.
Each storage owns its own client: no global credentials state.
Works with cloudpathlib’s local (mocked) clients for offline tests.
Prerequisites
Python 3.10+
Installation
With uv:
uv add fake-py-cloudpathlib-storage
Or with pip:
pip install fake-py-cloudpathlib-storage
Install the extras for the providers you need (s3, gcs, azure or all):
uv add "fake-py-cloudpathlib-storage[s3]"
uv add "fake-py-cloudpathlib-storage[gcs]"
uv add "fake-py-cloudpathlib-storage[azure]"
uv add "fake-py-cloudpathlib-storage[all]"
Documentation
Documentation is available on Read the Docs.
For guidelines on contributing check the Contributor guidelines.
Usage
Local cloud-alike file system storage
from fake import FAKER
from fakepy.cloudpathlib_storage.cloud import LocalFileSystemStorage
STORAGE = LocalFileSystemStorage(
bucket_name="bucket_name",
root_path="tmp", # Optional
rel_path="sub-tmp", # Optional
)
pdf_file = FAKER.pdf_file(storage=STORAGE)
STORAGE.exists(pdf_file)
LocalFileSystemStorage uses pathlib.Path, since cloudpathlib has no file:// backend. Files are stored under local_storage_dir (defaults to the system temporary directory). CloudpathlibFileSystemStorage is an alias. abspath() returns a standard absolute file:/// URI.
AWS S3
from fake import FAKER
from fakepy.cloudpathlib_storage.aws_s3 import AWSS3Storage
STORAGE = AWSS3Storage(
bucket_name="bucket_name",
root_path="tmp", # Optional
rel_path="sub-tmp", # Optional
# Credentials are optional too. If your AWS credentials are properly
# set in the ~/.aws/credentials, you don't need to send them
# explicitly.
credentials={
"key_id": "YOUR KEY ID",
"key_secret": "YOUR KEY SECRET"
},
)
pdf_file = FAKER.pdf_file(storage=STORAGE)
STORAGE.exists(pdf_file)
Additional S3Client options (session tokens, profiles, custom endpoints, cache settings, etc.) go in client_kwargs.
Google Cloud Storage
from fake import FAKER
from fakepy.cloudpathlib_storage.google_cloud_storage import (
GoogleCloudStorage,
)
STORAGE = GoogleCloudStorage(
bucket_name="bucket_name",
root_path="tmp", # Optional
rel_path="sub-tmp", # Optional
# Optional. Omit to use application default credentials.
credentials={"json_file_path": "/path/to/service-account.json"},
)
pdf_file = FAKER.pdf_file(storage=STORAGE)
STORAGE.exists(pdf_file)
json_file_path maps to GSClient’s application_credentials.
Azure Cloud Storage
from fake import FAKER
from fakepy.cloudpathlib_storage.azure_cloud_storage import (
AzureCloudStorage,
)
STORAGE = AzureCloudStorage(
bucket_name="bucket_name",
root_path="tmp", # Optional
rel_path="sub-tmp", # Optional
credentials={"connection_string": "YOUR CONNECTION STRING"},
)
pdf_file = FAKER.pdf_file(storage=STORAGE)
STORAGE.exists(pdf_file)
Azure paths use cloudpathlib’s az:// scheme. Other AzureBlobClient options may be passed through client_kwargs.
Offline cloud tests
Pass a cloudpathlib local client to test without touching real clouds:
from cloudpathlib.local import LocalS3Client
from fakepy.cloudpathlib_storage.aws_s3 import AWSS3Storage
client = LocalS3Client(local_storage_dir="/tmp/mock-cloud")
storage = AWSS3Storage("example", client=client)
filename = storage.generate_filename("txt", basename="sample")
storage.write_text(filename, "offline")
assert filename.read_text() == "offline"
storage.unlink(filename)
LocalGSClient and LocalAzureBlobClient work the same way. The latter requires a non-empty dummy connection_string.
Migrating from fake-py-pathy-storage
Package: fake-py-cloudpathlib-storage.
Imports: fakepy.cloudpathlib_storage instead of fakepy.pathy_storage.
Same CloudStorage, LocalFileSystemStorage, AWSS3Storage, GoogleCloudStorage and AzureCloudStorage classes. PathyFileSystemStorage becomes CloudpathlibFileSystemStorage.
Cloud paths are cloudpathlib CloudPath subclasses; local paths are pathlib.Path.
Each storage owns its client. Authentication no longer changes global provider settings. client and credentials/client_kwargs are mutually exclusive.
Cloud buckets/containers must already exist. Initialization does not provision resources or perform network existence checks. Local bucket directories are still created automatically.
Azure uses the az:// scheme instead of Pathy’s azure://.
Existing absolute path objects remain accepted, as in the original. This is not a sandbox for untrusted filenames.
Tests
Project uses uv for dependency management and running things.
uv sync --all-extras
uv run pytest
Or, using the Makefile:
make install
make test
Tests use isolated temporary directories and cloudpathlib’s local clients for AWS S3, Google Cloud Storage and Azure, so no real cloud accounts are needed. Code blocks in the documentation are tested too.
Writing documentation
Keep the following hierarchy.
=====
title
=====
header
======
sub-header
----------
sub-sub-header
~~~~~~~~~~~~~~
sub-sub-sub-header
^^^^^^^^^^^^^^^^^^
sub-sub-sub-sub-header
++++++++++++++++++++++
sub-sub-sub-sub-sub-header
**************************
License
MIT
Support
For security issues contact me at the e-mail given in the Author section.
For overall issues, go to GitHub.
Metadata
Release files for fake-py-cloudpathlib-storage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fake_py_cloudpathlib_storage-0.1.0.tar.gz | 28.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fake_py_cloudpathlib_storage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.3 kB
Release files / fake_py_cloudpathlib_storage-0.1.0.tar.gz
| Download URL | fake_py_cloudpathlib_storage-0.1.0.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9be744079cc43224ed357fcb52eb0bf8a8afa7628f5f3da351644ae76f608fec
|
|
BLAKE2b-256 checksum How to use checksums |
4176e0cf89ab6e81941f6707bbf23fef79775ac73ffc93017b641a5eb29699b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Release files / fake_py_cloudpathlib_storage-0.1.0-py3-none-any.whl
| Download URL | fake_py_cloudpathlib_storage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4880066d3fb9a9e9dd5271455365d25d01e0ebcfc4a7786afe8bccc3252af3fa
|
|
BLAKE2b-256 checksum How to use checksums |
f8d8eeb534c5425a3f1edebc3825fcf6a802ea9877ce7eafccc9a5ded3107d94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Security for fake-py-cloudpathlib-storage 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.