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:
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.
Configuration
Flags
--meilisearch-host: Host where the Meilisearch test server is running. For examplehttp://localhost. Default =http://127.0.0.1(This is the same ashttp://localhost).--meilisearch-port: Port where the Meilisearch test server is running. For example7700. 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 arefunction,module,package, orsession. 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 arenone= 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, orindex= 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_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:
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:
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.
Metadata
Release files for pytest-meilisearch 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_meilisearch-0.6.1.tar.gz | 40.2 kB | Without provenance | Details for pytest_meilisearch-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_meilisearch-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_meilisearch-0.6.1-py3-none-any.whl |
Total release size: 47.0 kB
Release files / pytest_meilisearch-0.6.1.tar.gz
| Download URL | pytest_meilisearch-0.6.1.tar.gz |
|---|---|
| Size | 40.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
347f1c4f27092c487b9d87c7d3b4900e867b1c29e2f607759a004b55329b81af
|
|
BLAKE2b-256 checksum How to use checksums |
e38b075b84cab9f7eddce6c3ecbeb48b7cb7975799b4fd62acacd50d1ab7061b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / pytest_meilisearch-0.6.1-py3-none-any.whl
| Download URL | pytest_meilisearch-0.6.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c0a0b827e3d4d35668385f1edd12a878d256d4d61b34ece97b99e6b11ed5da4
|
|
BLAKE2b-256 checksum How to use checksums |
4c51185c9979d790590ad42df14c9f44c14cdae7e15fc78bd541e7b4444b884f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Security for pytest-meilisearch 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.