Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poogles/pytest-gcs
Pytest fixtures for creating and interacting with a local instance of GCS.
https://github.com/poogles/pytest-gcs
gcs google-cloud google-cloud-sto pytest pytest-plugin
Last synced: 4 days ago
JSON representation
Pytest fixtures for creating and interacting with a local instance of GCS.
- Host: GitHub
- URL: https://github.com/poogles/pytest-gcs
- Owner: Poogles
- License: mit
- Created: 2024-02-17T18:44:41.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-03-01T16:36:17.000Z (10 months ago)
- Last Synced: 2024-12-06T21:56:20.079Z (27 days ago)
- Topics: gcs, google-cloud, google-cloud-sto, pytest, pytest-plugin
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Pytest GCS
This is a pytest plugin in similar vein to [pytest-postgres](https://github.com/ClearcodeHQ/pytest-postgresql) and [pytest-kafka](https://pypi.org/project/pytest-kafka/).
This would have been much more painful without [Mirakuru](https://github.com/ClearcodeHQ/mirakuru)
and [fake-gcs-server](https://github.com/fsouza/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.```sh
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:
```sh
pip install pytest-gcs
```### Demo
```python
# 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 GCSExecutordef 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.
```sh
# 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.