This is a pytest plugin in similar vein to pytest-postgres and pytest-kafka.
This would have been much more painful without Mirakuru and fake-gcs-server; this is a simple wrapper around those tools.
This tool requires you to have a copy of the fake-gcs-server
binary somewhere on your path.
Depending upon your architecture you'll need a different version of the tool.
wget https://github.com/fsouza/fake-gcs-server/releases/download/v1.47.8/fake-gcs-server_1.47.8_Linux_amd64.tar.gz
tar -xvf fake-gcs-server_1.47.8_Linux_amd64.tar.gz
mv fake-gcs-server /usr/local/bin
To install this library:
pip install pytest-gcs
# conftest.py
from pytest_gcs.factories import client as gcs_client
from pytest_gcs.factories import proc as gcs_process
# Create a process and a local client that targets that process.
gcs_proc = gcs_process.gcs_proc()
gcslocal = gcs_client.gcslocal("gcs_proc")
# tests/test_gcs.py
from google.cloud import storage
from pytest_gcs.executor.process import GCSExecutor
def test_can_create_gcs_bucket(gcs_proc: GCSExecutor, gcslocal: storage.Client) -> None:
"""MVP to ensure everything works."""
bucket = "test_base"
gcslocal.create_bucket(bucket)
buckets = [x.name for x in gcslocal.list_buckets()]
assert bucket in buckets
PRs are accepted.
# Install the dependencies with:
pip install .[test]
# Install pre-commit hooks.
pre-commit install
# Validate everything passes.
pre-commit run --all
# Run the tests.
pytest tests/
- Implement the events outputs,
-event.bucket
,-event.list
, etc.