GCS fixtures and fixture factories for Pytest.
Project description
Pytest GCS
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.
Installation
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
Demo
# 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
Contributing
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/
TODOs
- Implement the events outputs,
-event.bucket
,-event.list
, etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest-gcs-0.0.3.tar.gz
(8.7 kB
view details)
Built Distribution
File details
Details for the file pytest-gcs-0.0.3.tar.gz
.
File metadata
- Download URL: pytest-gcs-0.0.3.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e835c0ed182e2684ffe4657975fa108d58fa9bc448ffed12013f3bf3bae387e |
|
MD5 | 63567f1a5e527ee2ee0992d98c02cb98 |
|
BLAKE2b-256 | 7a0988bb2f39d07ff171862f6df61c2f84f926402547ce005b34128593247315 |
File details
Details for the file pytest_gcs-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pytest_gcs-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b85ea4f292e42a7a1000deff25ce1fac6ace93756df3ec33d0fd3232773dfc19 |
|
MD5 | 61b002553748d4c35d81c94d16f6db03 |
|
BLAKE2b-256 | 2a3b181b6d62c14c5b193ff18e4010fb2fa0f0368137178889229e91f315a66d |