pytest-gcs


Namepytest-gcs JSON
Version 0.0.3 PyPI version JSON
download
home_page
SummaryGCS fixtures and fixture factories for Pytest.
upload_time2024-03-01 16:36:59
maintainer
docs_urlNone
author
requires_python>=3.8
licenseCopyright (c) 2024 Sam Pegler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords tests pytest fixture gcs
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## 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 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.

```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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pytest-gcs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "tests,pytest,fixture,gcs",
    "author": "",
    "author_email": "Sam Pegler <sam@sampegler.co.uk>",
    "download_url": "https://files.pythonhosted.org/packages/7a/09/88bb2f39d07ff171862f6df61c2f84f926402547ce005b34128593247315/pytest-gcs-0.0.3.tar.gz",
    "platform": null,
    "description": "## Pytest GCS\n\nThis 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/).\n\nThis would have been much more painful without [Mirakuru](https://github.com/ClearcodeHQ/mirakuru)\nand [fake-gcs-server](https://github.com/fsouza/fake-gcs-server); this is a simple wrapper around\nthose tools.\n\n\n### Installation\n\nThis tool requires you to have a copy of the `fake-gcs-server` binary somewhere on your path.\nDepending upon your architecture you'll need a different version of the tool.\n\n```sh\nwget https://github.com/fsouza/fake-gcs-server/releases/download/v1.47.8/fake-gcs-server_1.47.8_Linux_amd64.tar.gz\ntar -xvf fake-gcs-server_1.47.8_Linux_amd64.tar.gz\nmv fake-gcs-server /usr/local/bin\n```\n\nTo install this library:\n\n```sh\npip install pytest-gcs\n```\n\n\n### Demo\n\n```python\n# conftest.py\nfrom pytest_gcs.factories import client as gcs_client\nfrom pytest_gcs.factories import proc as gcs_process\n\n# Create a process and a local client that targets that process.\ngcs_proc = gcs_process.gcs_proc()\ngcslocal = gcs_client.gcslocal(\"gcs_proc\")\n\n# tests/test_gcs.py\nfrom google.cloud import storage\nfrom pytest_gcs.executor.process import GCSExecutor\n\n\ndef test_can_create_gcs_bucket(gcs_proc: GCSExecutor, gcslocal: storage.Client) -> None:\n    \"\"\"MVP to ensure everything works.\"\"\"\n    bucket = \"test_base\"\n    gcslocal.create_bucket(bucket)\n    buckets = [x.name for x in gcslocal.list_buckets()]\n\n    assert bucket in buckets\n```\n\n\n### Contributing\n\nPRs are accepted.\n\n```sh\n# Install the dependencies with:\npip install .[test]\n# Install pre-commit hooks.\npre-commit install\n# Validate everything passes.\npre-commit run --all\n# Run the tests.\npytest tests/\n```\n\n\n### TODOs\n\n* Implement the events outputs, `-event.bucket`, `-event.list`, etc.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2024 Sam Pegler  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "GCS fixtures and fixture factories for Pytest.",
    "version": "0.0.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/Poogles/pytest-gcs/issues",
        "Source": "https://github.com/Poogles/pytest-gcs"
    },
    "split_keywords": [
        "tests",
        "pytest",
        "fixture",
        "gcs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a3b181b6d62c14c5b193ff18e4010fb2fa0f0368137178889229e91f315a66d",
                "md5": "61b002553748d4c35d81c94d16f6db03",
                "sha256": "b85ea4f292e42a7a1000deff25ce1fac6ace93756df3ec33d0fd3232773dfc19"
            },
            "downloads": -1,
            "filename": "pytest_gcs-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "61b002553748d4c35d81c94d16f6db03",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8882,
            "upload_time": "2024-03-01T16:36:57",
            "upload_time_iso_8601": "2024-03-01T16:36:57.007173Z",
            "url": "https://files.pythonhosted.org/packages/2a/3b/181b6d62c14c5b193ff18e4010fb2fa0f0368137178889229e91f315a66d/pytest_gcs-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a0988bb2f39d07ff171862f6df61c2f84f926402547ce005b34128593247315",
                "md5": "63567f1a5e527ee2ee0992d98c02cb98",
                "sha256": "0e835c0ed182e2684ffe4657975fa108d58fa9bc448ffed12013f3bf3bae387e"
            },
            "downloads": -1,
            "filename": "pytest-gcs-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "63567f1a5e527ee2ee0992d98c02cb98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8658,
            "upload_time": "2024-03-01T16:36:59",
            "upload_time_iso_8601": "2024-03-01T16:36:59.272969Z",
            "url": "https://files.pythonhosted.org/packages/7a/09/88bb2f39d07ff171862f6df61c2f84f926402547ce005b34128593247315/pytest-gcs-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-01 16:36:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Poogles",
    "github_project": "pytest-gcs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytest-gcs"
}
        
Elapsed time: 2.82598s