pytest-meilisearch


Namepytest-meilisearch JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/sanders41/pytest-meilisearch
SummaryPytest helpers for testing projects using Meilisearch
upload_time2024-02-12 15:48:24
maintainer
docs_urlNone
authorPaul Sanders
requires_python>=3.8,<4.0
licenseMIT
keywords meilisearch python pytest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-meilisearch

[![Test Status](https://github.com/sanders41/pytest-meilisearch/workflows/Testing/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_client and client fixtures. Valid
  settings are `function`, `module`, `package`, or `session`. Default = `function`.
- `meilisearch_clear_indexes`: Controls is indexes are deleted after each tests. This can be useful
  to ensure that tests don't interfer with each other. Valid options are `none` = indexes are not
  deleted, `async` = indexes are asyncronously deleted after each test, or `sync` = 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_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_client.index(index_name)
        result = await index.get_documents()
        assert result.results == docs
    ```

  - sync:

    ```py
    def test_my_func(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 = 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": "https://github.com/sanders41/pytest-meilisearch",
    "name": "pytest-meilisearch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "meilisearch,python,pytest",
    "author": "Paul Sanders",
    "author_email": "psanders1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/48/9c/882caf20191e1480e25d8bfb92581a67944880825112424515b1b7e670b4/pytest_meilisearch-0.4.0.tar.gz",
    "platform": null,
    "description": "# pytest-meilisearch\n\n[![Test Status](https://github.com/sanders41/pytest-meilisearch/workflows/Testing/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_client and client fixtures. Valid\n  settings are `function`, `module`, `package`, or `session`. Default = `function`.\n- `meilisearch_clear_indexes`: Controls is indexes are deleted after each tests. This can be useful\n  to ensure that tests don't interfer with each other. Valid options are `none` = indexes are not\n  deleted, `async` = indexes are asyncronously deleted after each test, or `sync` = 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_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_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(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 = 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",
    "summary": "Pytest helpers for testing projects using Meilisearch",
    "version": "0.4.0",
    "project_urls": {
        "Documentation": "https://github.com/sanders41/pytest-meilisearch",
        "Homepage": "https://github.com/sanders41/pytest-meilisearch",
        "Repository": "https://github.com/sanders41/pytest-meilisearch"
    },
    "split_keywords": [
        "meilisearch",
        "python",
        "pytest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7864c4a3778ed5e303762a21dc183f6e0caabaafe894c6f36832a73b3c5b9139",
                "md5": "b32d8e457edf5875ab064930d9f86980",
                "sha256": "ff45b301a99627fffc0d222b5c93021995599e7c2000eba907f6b08b2302cba9"
            },
            "downloads": -1,
            "filename": "pytest_meilisearch-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b32d8e457edf5875ab064930d9f86980",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5983,
            "upload_time": "2024-02-12T15:48:22",
            "upload_time_iso_8601": "2024-02-12T15:48:22.724337Z",
            "url": "https://files.pythonhosted.org/packages/78/64/c4a3778ed5e303762a21dc183f6e0caabaafe894c6f36832a73b3c5b9139/pytest_meilisearch-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "489c882caf20191e1480e25d8bfb92581a67944880825112424515b1b7e670b4",
                "md5": "41ecaac313b3b15674da137cae9c4126",
                "sha256": "a94c7abeca3174974d702f00464faa55c01186b2a259b3501e6c1786c9cd51f1"
            },
            "downloads": -1,
            "filename": "pytest_meilisearch-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "41ecaac313b3b15674da137cae9c4126",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 4791,
            "upload_time": "2024-02-12T15:48:24",
            "upload_time_iso_8601": "2024-02-12T15:48:24.327480Z",
            "url": "https://files.pythonhosted.org/packages/48/9c/882caf20191e1480e25d8bfb92581a67944880825112424515b1b7e670b4/pytest_meilisearch-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-12 15:48:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sanders41",
    "github_project": "pytest-meilisearch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytest-meilisearch"
}
        
Elapsed time: 0.18252s