pytest-meilisearch


Namepytest-meilisearch JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummaryPytest helpers for testing projects using Meilisearch
upload_time2024-08-27 00:08:15
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2023 Paul Sanders 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 meilisearch pytest python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-meilisearch

[![Tests Status](https://github.com/sanders41/pytest-meilisearch/actions/workflows/testing.yml/badge.svg?branch=main&event=push)](https://github.com/sanders41/pytest-meilisearch/actions?query=workflow%3ATesting+branch%3Amain+event%3Apush)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/pytest-meilisearch/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/pytest-meilisearch/main)
[![PyPI version](https://badge.fury.io/py/pytest-meilisearch.svg)](https://badge.fury.io/py/pytest-meilisearch)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-meilisearch?color=5cc141)](https://github.com/sanders41/pytest-meilisearch)

pytest helpers for testing Python projects using Meilisearch.

## Installation

Using a virtual environment is recommended for installing this package. Once the virtual
environment is created and activated, install the package with:

```sh
pip install pytest-meilisearch
```

## Usage

Note that to use any of the async options you also need to install an async test helper such as
[pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio).

### Configuration

#### Flags

- `--meilisearch-host`: Host where the Meilisearch test server is running. For example
  `http://localhost`. Default = `http://127.0.0.1` (This is the same as `http://localhost`).
- `--meilisearch-port`: Port where the Meilisearch test server is running. For example `7700`.
  Default = `7700`.
- `--meilisearch-master-key`: The master key for the Meilisearch test server. Default = `None`.

#### Settings

- `meilisearch_client_scope`: Modify the scope of the async_meilisearch_client and
  meilisearch_client fixtures. Valid settings are `function`, `module`, `package`, or `session`.
  Default = `function`.
- `meilisearch_clear`: Controls if either documents or indexes are deleted after each tests. This
  can be useful to ensure that tests don't interfer with each other. Valid options are
  `none` = documents and indexes are not deleted, `async_document` = documents are asyncronously
  deleted after each test, `async_index` = indexes are asyncronously deleted after each test,
  `document` = documents are syncronously deleted after each test, or `index` = indexes are
  syncronously deleted between each test. Default = `none`.

## Examples

- Testing that your function that adds documents to an index is successful:

  - async:

    ```py
    async def test_my_func(async_meilisearch_client):
        docs = [
            {"id": 1, "title": "Ready Player One"},
            {"id": 2, "title": "The Hitchhiker's Guide to the Galaxy"},
        ]
        index_name = "books"
        await my_func(index_name, docs)
        index = async_meilisearch_client.index(index_name)
        result = await index.get_documents()
        assert result.results == docs
    ```

  - sync:

    ```py
    def test_my_func(meilisearch_client):
        docs = [
            {"id": 1, "title": "Ready Player One"},
            {"id": 2, "title": "The Hitchhiker's Guide to the Galaxy"},
        ]
        index_name = "books"
        my_func(index_name, docs)
        index = meilisearch_client.index(index_name)
        result = index.get_documents()
        assert result.results == docs
    ```

- Testing that your search is successful:

  - async:

    ```py
    async def test_my_func(async_index_with_documents):
        docs = [
            {"id": 1, "title": "Ready Player One"},
            {"id": 2, "title": "The Hitchhiker's Guide to the Galaxy"},
        ]
        index_name = "books"
        index = await async_index_with_documents(docs, index_name)
        results = await my_func("Ready Player One")
        expected = "Ready Player One"  # Whatever you expect to be returned
        assert result == expected
    ```

  - sync:

    ```py
    def test_my_func(index_with_documents):
        docs = [
            {"id": 1, "title": "Ready Player One"},
            {"id": 2, "title": "The Hitchhiker's Guide to the Galaxy"},
        ]
        index_name = "books"
        index = index_with_documents(docs, index_name)
        results = my_func("Ready Player One")
        expected = "Ready Player One"  # Whatever you expect to be returned
        assert result == expected
    ```

## Contributing

If you are interested in contributing to this project please see our
[contributing guide](CONTRIBUTING.md).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytest-meilisearch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "meilisearch, pytest, python",
    "author": null,
    "author_email": "Paul Sanders <paul@paulsanders.dev>",
    "download_url": "https://files.pythonhosted.org/packages/7e/0c/6fd75113da3f6d0e1055cd19d8c5233031218dd87b671d9d12206d019e7b/pytest_meilisearch-0.6.0.tar.gz",
    "platform": null,
    "description": "# pytest-meilisearch\n\n[![Tests Status](https://github.com/sanders41/pytest-meilisearch/actions/workflows/testing.yml/badge.svg?branch=main&event=push)](https://github.com/sanders41/pytest-meilisearch/actions?query=workflow%3ATesting+branch%3Amain+event%3Apush)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/pytest-meilisearch/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/pytest-meilisearch/main)\n[![PyPI version](https://badge.fury.io/py/pytest-meilisearch.svg)](https://badge.fury.io/py/pytest-meilisearch)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-meilisearch?color=5cc141)](https://github.com/sanders41/pytest-meilisearch)\n\npytest helpers for testing Python projects using Meilisearch.\n\n## Installation\n\nUsing a virtual environment is recommended for installing this package. Once the virtual\nenvironment is created and activated, install the package with:\n\n```sh\npip install pytest-meilisearch\n```\n\n## Usage\n\nNote that to use any of the async options you also need to install an async test helper such as\n[pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio).\n\n### Configuration\n\n#### Flags\n\n- `--meilisearch-host`: Host where the Meilisearch test server is running. For example\n  `http://localhost`. Default = `http://127.0.0.1` (This is the same as `http://localhost`).\n- `--meilisearch-port`: Port where the Meilisearch test server is running. For example `7700`.\n  Default = `7700`.\n- `--meilisearch-master-key`: The master key for the Meilisearch test server. Default = `None`.\n\n#### Settings\n\n- `meilisearch_client_scope`: Modify the scope of the async_meilisearch_client and\n  meilisearch_client fixtures. Valid settings are `function`, `module`, `package`, or `session`.\n  Default = `function`.\n- `meilisearch_clear`: Controls if either documents or indexes are deleted after each tests. This\n  can be useful to ensure that tests don't interfer with each other. Valid options are\n  `none` = documents and indexes are not deleted, `async_document` = documents are asyncronously\n  deleted after each test, `async_index` = indexes are asyncronously deleted after each test,\n  `document` = documents are syncronously deleted after each test, or `index` = indexes are\n  syncronously deleted between each test. Default = `none`.\n\n## Examples\n\n- Testing that your function that adds documents to an index is successful:\n\n  - async:\n\n    ```py\n    async def test_my_func(async_meilisearch_client):\n        docs = [\n            {\"id\": 1, \"title\": \"Ready Player One\"},\n            {\"id\": 2, \"title\": \"The Hitchhiker's Guide to the Galaxy\"},\n        ]\n        index_name = \"books\"\n        await my_func(index_name, docs)\n        index = async_meilisearch_client.index(index_name)\n        result = await index.get_documents()\n        assert result.results == docs\n    ```\n\n  - sync:\n\n    ```py\n    def test_my_func(meilisearch_client):\n        docs = [\n            {\"id\": 1, \"title\": \"Ready Player One\"},\n            {\"id\": 2, \"title\": \"The Hitchhiker's Guide to the Galaxy\"},\n        ]\n        index_name = \"books\"\n        my_func(index_name, docs)\n        index = meilisearch_client.index(index_name)\n        result = index.get_documents()\n        assert result.results == docs\n    ```\n\n- Testing that your search is successful:\n\n  - async:\n\n    ```py\n    async def test_my_func(async_index_with_documents):\n        docs = [\n            {\"id\": 1, \"title\": \"Ready Player One\"},\n            {\"id\": 2, \"title\": \"The Hitchhiker's Guide to the Galaxy\"},\n        ]\n        index_name = \"books\"\n        index = await async_index_with_documents(docs, index_name)\n        results = await my_func(\"Ready Player One\")\n        expected = \"Ready Player One\"  # Whatever you expect to be returned\n        assert result == expected\n    ```\n\n  - sync:\n\n    ```py\n    def test_my_func(index_with_documents):\n        docs = [\n            {\"id\": 1, \"title\": \"Ready Player One\"},\n            {\"id\": 2, \"title\": \"The Hitchhiker's Guide to the Galaxy\"},\n        ]\n        index_name = \"books\"\n        index = index_with_documents(docs, index_name)\n        results = my_func(\"Ready Player One\")\n        expected = \"Ready Player One\"  # Whatever you expect to be returned\n        assert result == expected\n    ```\n\n## Contributing\n\nIf you are interested in contributing to this project please see our\n[contributing guide](CONTRIBUTING.md).\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Paul Sanders  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": "Pytest helpers for testing projects using Meilisearch",
    "version": "0.6.0",
    "project_urls": null,
    "split_keywords": [
        "meilisearch",
        " pytest",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20a240c3b8a6a82f38855b8fab0ca0065a758f3255ca4aed779a00b368ef6eb3",
                "md5": "abd69e31a216739a1f4fbc78c1243471",
                "sha256": "5406afba7df29b51e1f678417f719425912c765ac218005b5039a3c6c5dafe5d"
            },
            "downloads": -1,
            "filename": "pytest_meilisearch-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "abd69e31a216739a1f4fbc78c1243471",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6764,
            "upload_time": "2024-08-27T00:08:14",
            "upload_time_iso_8601": "2024-08-27T00:08:14.852074Z",
            "url": "https://files.pythonhosted.org/packages/20/a2/40c3b8a6a82f38855b8fab0ca0065a758f3255ca4aed779a00b368ef6eb3/pytest_meilisearch-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e0c6fd75113da3f6d0e1055cd19d8c5233031218dd87b671d9d12206d019e7b",
                "md5": "44b8a78f4c0b3f2063ed91b40c207336",
                "sha256": "1779300b5cfe2f90a3a8769fce6db6c2a17beb1b0e050fd0287281501d9f1222"
            },
            "downloads": -1,
            "filename": "pytest_meilisearch-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "44b8a78f4c0b3f2063ed91b40c207336",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 40227,
            "upload_time": "2024-08-27T00:08:15",
            "upload_time_iso_8601": "2024-08-27T00:08:15.872265Z",
            "url": "https://files.pythonhosted.org/packages/7e/0c/6fd75113da3f6d0e1055cd19d8c5233031218dd87b671d9d12206d019e7b/pytest_meilisearch-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-27 00:08:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pytest-meilisearch"
}
        
Elapsed time: 0.34969s