Skip to main content

pytest-meilisearch

Test Status pre-commit.ci status PyPI version PyPI - Python Version

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:

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. In order to use --start-meilisearch Docker has to be installed.

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.
  • --start-meilisearch: Start a Meilisearch Docker container before running the tests. For this to work Docker has to be installed first. Default = False.
  • --meilisearch-version: When using --start-meilisearch the this flag will set the version of Meilisearch to start. Default = latest.
  • --meilisearch-start-timeout: The number of seconds to wait for Meilisearch to start before timing out. Default = 120.

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:

      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:

      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:

      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:

      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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_meilisearch-0.3.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_meilisearch-0.3.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_meilisearch-0.3.1.tar.gz.

File metadata

  • Download URL: pytest_meilisearch-0.3.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.10.12 Linux/6.2.0-1015-azure

File hashes

Hashes for pytest_meilisearch-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e3f8355d7c0c2789215c2ad475392a88bcfb2d6ea9703c3147861ee2c87f587a
MD5 88ec1fc222d31e7c9559dfab2daf745f
BLAKE2b-256 bcc12ca803a1b24fe735ebf4d0c83a9e3d022b6a01bdf1ce227b814aa32964ef

See more details on using hashes here.

File details

Details for the file pytest_meilisearch-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_meilisearch-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.10.12 Linux/6.2.0-1015-azure

File hashes

Hashes for pytest_meilisearch-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce04f6e3eb9e4c7d97678c3c4eba85c8947a95f05c31df96044cdab2a99617ba
MD5 f1c858fea4853530305f9b277226847b
BLAKE2b-256 3499b4f298983c13dd30550647cfa4d278e7622c51743742706d0a9d164eb73c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page