repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
meilisearch/meilisearch-python | import pytest
from meilisearch.models.document import Document
def test_getattr_not_found():
document = Document({"field1": "test 1", "field2": "test 2"})
with pytest.raises( | AttributeError) | pytest.raises | variable | tests/models/test_document.py | test_getattr_not_found | 22 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchTimeoutError
from meilisearch.models.task import Task
def test_wait_for_task_interval_custom(index_with_documents, small_movies):
"""Tests call to wait for an update with custom interval."""
index = index_with_documents()
... | "processing" | assert | string_literal | tests/index/test_index_wait_for_task.py | test_wait_for_task_interval_custom | 39 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
from tests.common import INDEX_UID, REMOTE_MS_1, REMOTE_MS_2
from tests.test_utils import reset_network_config
def test_basic_multi_search(client, empty_index):
"""Tests multi-search on two indexes."""
empty_index("indexA")
empty_index("inde... | 20 | assert | numeric_literal | tests/client/test_client_multi_search_meilisearch.py | test_basic_multi_search | 19 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
from tests.common import INDEX_UID, REMOTE_MS_1, REMOTE_MS_2
from tests.test_utils import reset_network_config
def test_basic_multi_search(client, empty_index):
"""Tests multi-search on two indexes."""
empty_index("indexA")
empty_index("inde... | "indexB" | assert | string_literal | tests/client/test_client_multi_search_meilisearch.py | test_basic_multi_search | 18 | null | |
meilisearch/meilisearch-python | NEW_SEPARATOR_TOKENS = ["|", "…"]
NEW_NON_SEPARATOR_TOKENS = ["@", "#"]
def test_update_non_separator_tokens(empty_index):
"""Tests updating the non separator tokens."""
index = empty_index()
task = index.update_non_separator_tokens(NEW_NON_SEPARATOR_TOKENS)
task = index.wait_for_task(task.task_... | non_separator_tokens | assert | variable | tests/settings/test_settings_text_separators_meilisearch.py | test_update_non_separator_tokens | 38 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.client import Client
from meilisearch.errors import MeilisearchApiError
from meilisearch.index import Index
from tests import BASE_URL, MASTER_KEY, common
@pytest.mark.usefixtures("indexes_sample")
def test_get_indexes(client):
"""Tests getting all ind... | 3 | assert | numeric_literal | tests/index/test_index.py | test_get_indexes | 55 | null | |
meilisearch/meilisearch-python | NEW_SEPARATOR_TOKENS = ["|", "…"]
NEW_NON_SEPARATOR_TOKENS = ["@", "#"]
def test_update_separator_tokens(empty_index):
"""Tests updating the separator tokens."""
index = empty_index()
task = index.update_separator_tokens(NEW_SEPARATOR_TOKENS)
task = index.wait_for_task(task.task_uid)
assert... | "succeeded" | assert | string_literal | tests/settings/test_settings_text_separators_meilisearch.py | test_update_separator_tokens | 22 | null | |
meilisearch/meilisearch-python | from collections import Counter
import pytest
def test_custom_search_params_with_crop_marker(index_with_documents):
"""Tests search with a list of one string in query params."""
response = index_with_documents().search(
"dragon",
{
"limit": 1,
"attributesToCrop": ["over... | 2 | assert | numeric_literal | tests/index/test_index_search_meilisearch.py | test_custom_search_params_with_crop_marker | 133 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.document import Document
def test_doc_init():
d = {"field1": "test 1", "field2": "test 2"}
document = Document(d)
assert dict(document) == | d | assert | variable | tests/models/test_document.py | test_doc_init | 12 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchTimeoutError
from meilisearch.models.task import Task
def test_wait_for_task_default(index_with_documents):
"""Tests waiting for an update with default parameters."""
index = index_with_documents()
response = index.add_... | None | assert | none_literal | tests/index/test_index_wait_for_task.py | test_wait_for_task_default | 15 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.index import Faceting
DEFAULT_MAX_VALUE_PER_FACET = 100
DEFAULT_SORT_FACET_VALUES_BY = {"*": "alpha"}
NEW_MAX_VALUE_PER_FACET = {"maxValuesPerFacet": 200}
def test_get_faceting_settings(empty_index):
response = empty_index().get_faceting_settings()
assert DEFAULT_MAX_V... | response.max_values_per_facet | assert | complex_expr | tests/settings/test_setting_faceting.py | test_get_faceting_settings | 13 | null | |
meilisearch/meilisearch-python | import datetime
from copy import deepcopy
import pytest
import meilisearch
from meilisearch.errors import MeilisearchApiError
from tests import BASE_URL
def test_generate_tenant_token_no_api_key(client, get_private_key):
# Make a copy of the client so we don't change the value in the session scoped fixture as th... | ValueError) | pytest.raises | variable | tests/client/test_client_tenant_token.py | test_generate_tenant_token_no_api_key | 63 | null | |
meilisearch/meilisearch-python | SORTABLE_ATTRIBUTES = ["title", "release_date"]
def test_update_sortable_attributes(empty_index):
"""Tests updating the sortable attributes."""
index = empty_index()
response = index.update_sortable_attributes(SORTABLE_ATTRIBUTES)
index.wait_for_task(response.task_uid)
get_attributes = index.get_so... | get_attributes | assert | variable | tests/settings/test_settings_sortable_attributes_meilisearch.py | test_update_sortable_attributes | 20 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
def test_swap_indexes_with_one_that_does_not_exist(client, empty_index):
"""Tests swap indexes with one that does not exist."""
index = empty_index("index_A")
swapTask = client.swap_indexes(
[
{
"indexes":... | "index_not_found" | assert | string_literal | tests/client/test_client_swap_meilisearch.py | test_swap_indexes_with_one_that_does_not_exist | 46 | null | |
meilisearch/meilisearch-python | DISPLAYED_ATTRIBUTES = ["id", "release_date", "title", "poster", "overview", "genre"]
def test_get_displayed_attributes(empty_index, small_movies):
"""Tests getting the displayed attributes before and after indexing a dataset."""
index = empty_index()
response = index.get_displayed_attributes()
assert... | ["*"] | assert | collection | tests/settings/test_settings_displayed_attributes_meilisearch.py | test_get_displayed_attributes | 10 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.embedders import (
CompositeEmbedder,
HuggingFaceEmbedder,
OpenAiEmbedder,
PoolingType,
UserProvidedEmbedder,
)
def test_get_default_embedders(empty_index):
"""Tests getting default embedders."""
response = empty_index().get_embedders()
assert re... | None | assert | none_literal | tests/settings/test_settings_embedders.py | test_get_default_embedders | 18 | null | |
meilisearch/meilisearch-python | def test_facet_search_with_empty_query(index_with_documents_and_facets):
"""Tests facet search with a empty query."""
response = index_with_documents_and_facets().facet_search("genre")
assert isinstance(response, dict)
assert len(response["facetHits"]) == | 4 | assert | numeric_literal | tests/index/test_index_facet_search_meilisearch.py | test_facet_search_with_empty_query | 16 | null | |
meilisearch/meilisearch-python | NEW_DISTINCT_ATTRIBUTE = "title"
DEFAULT_DISTINCT_ATTRIBUTE = None
def test_update_distinct_at_to_none(empty_index):
"""Tests updating distinct attribute at null."""
index = empty_index()
# Update the settings first
response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE)
update = index.w... | "succeeded" | assert | string_literal | tests/settings/test_settings_distinct_attribute_meilisearch.py | test_update_distinct_at_to_none | 26 | null | |
meilisearch/meilisearch-python | from meilisearch.models.index import IndexStats
def test_get_stats_default(index_with_documents):
"""Tests getting stats of a non-empty index."""
response = index_with_documents().get_stats()
assert isinstance(response, IndexStats)
assert response.number_of_documents == 31
assert hasattr(response.f... | 11 | assert | numeric_literal | tests/index/test_index_stats_meilisearch.py | test_get_stats_default | 17 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.embedders import OpenAiEmbedder, UserProvidedEmbedder
def new_settings(new_embedders):
return {
"rankingRules": ["typo", "words"],
"searchableAttributes": ["title", "overview"],
"embedders": new_embedders,
}
def test_get_settings_default(empty_ind... | {} | assert | collection | tests/settings/test_settings.py | test_get_settings_default | 49 | null | |
meilisearch/meilisearch-python | NEW_DISTINCT_ATTRIBUTE = "title"
DEFAULT_DISTINCT_ATTRIBUTE = None
def test_get_distinct_attribute(empty_index):
"""Tests geting the distinct attribute."""
response = empty_index().get_distinct_attribute()
assert response == | DEFAULT_DISTINCT_ATTRIBUTE | assert | variable | tests/settings/test_settings_distinct_attribute_meilisearch.py | test_get_distinct_attribute | 8 | null | |
meilisearch/meilisearch-python | import re
from meilisearch.version import __version__, qualified_version
def test_get_qualified_version():
assert qualified_version() == | f"Meilisearch Python (v{__version__})" | assert | string_literal | tests/client/test_version.py | test_get_qualified_version | 13 | null | |
meilisearch/meilisearch-python | NEW_SYNONYMS = {"hp": ["harry potter"]}
def test_get_synonyms_default(empty_index):
"""Tests getting default synonyms."""
response = empty_index().get_synonyms()
assert response == | {} | assert | collection | tests/settings/test_settings_synonyms_meilisearch.py | test_get_synonyms_default | 7 | null | |
meilisearch/meilisearch-python | NEW_STOP_WORDS = ["of", "the"]
def test_update_stop_words(empty_index):
"""Tests updating the stop words."""
index = empty_index()
response = index.update_stop_words(NEW_STOP_WORDS)
update = index.wait_for_task(response.task_uid)
assert update.status == | "succeeded" | assert | string_literal | tests/settings/test_settings_stop_words_meilisearch.py | test_update_stop_words | 15 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_create_chat_completion_stream_false_raises_error(client):
"""Test that stream=False raises ValueError."""
messages = [{"role": "user", "content": "Test"}]
... | ValueError, match="Non-streaming chat completions are not supported") | pytest.raises | complex_expr | tests/client/test_chat_completions.py | test_create_chat_completion_stream_false_raises_error | 65 | null | |
meilisearch/meilisearch-python | def test_update_experimental_features(client):
"""Test updating experimental features."""
# Enable multimodal
response = client.update_experimental_features({"multimodal": True})
assert isinstance(response, dict)
assert response.get("multimodal") is True
# Disable multimodal
response = clie... | False | assert | bool_literal | tests/client/test_experimental_features.py | test_update_experimental_features | 22 | null | |
meilisearch/meilisearch-python | from collections import Counter
import pytest
def test_custom_search_params_with_facets_distribution(index_with_documents):
index = index_with_documents()
update = index.update_filterable_attributes(["genre"])
index.wait_for_task(update.task_uid)
response = index.search("world", {"facets": ["genre"]})... | 3 | assert | numeric_literal | tests/index/test_index_search_meilisearch.py | test_custom_search_params_with_facets_distribution | 204 | null | |
meilisearch/meilisearch-python | import base64
import json
import os
from pathlib import Path
import pytest
import requests
from meilisearch import Client
from meilisearch.errors import MeilisearchApiError
from tests import common
VOYAGE_API_KEY = os.getenv("VOYAGE_API_KEY")
INDEX_UID = "multi-modal-search-test"
EMBEDDER_NAME = "multimodal"
DATAS... | "Captain Marvel" | assert | string_literal | tests/client/test_multimodal.py | test_text_query | TestMultimodalSearch | 242 | null |
meilisearch/meilisearch-python | import pytest
import meilisearch
from tests import BASE_URL, MASTER_KEY
def test_index_inherits_custom_headers():
custom_headers = {"header_key_1": "header_value_1", "header_key_2": "header_value_2"}
client = meilisearch.Client("127.0.0.1:7700", api_key=None, custom_headers=custom_headers)
index = client... | custom_headers.items() | assert | func_call | tests/client/test_client.py | test_index_inherits_custom_headers | 70 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
import meilisearch
from meilisearch.errors import MeilisearchApiError, version_error_hint_message
from tests import BASE_URL, MASTER_KEY
def test_version_error_hint_message():
mock_response = requests.models.Response()
mock_response.status_code = ... | str(e.value) | assert | func_call | tests/errors/test_api_error_meilisearch.py | test_version_error_hint_message | 51 | null | |
meilisearch/meilisearch-python | def test_facet_search_with_attributes_to_search_on(index_with_documents_and_facets):
"""Tests facet search with optional parameter attributesToSearchOn."""
response = index_with_documents_and_facets().facet_search(
"genre", "action", {"q": "aquaman", "attributesToSearchOn": ["overview"]}
)
asser... | 0 | assert | numeric_literal | tests/index/test_index_facet_search_meilisearch.py | test_facet_search_with_attributes_to_search_on | 47 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_create_chat_completion_json_decode_error(client):
"""Test that malformed JSON raises MeilisearchCommunicationError."""
dummy_lines = [
b'data: {"inv... | MeilisearchCommunicationError, match="Failed to parse chat chunk") | pytest.raises | complex_expr | tests/client/test_chat_completions.py | test_create_chat_completion_json_decode_error | 79 | null | |
meilisearch/meilisearch-python | import json
from datetime import datetime
from json import JSONEncoder
from math import ceil
from uuid import UUID, uuid4
from warnings import catch_warnings
import pytest
from meilisearch.errors import MeilisearchApiError
from meilisearch.models.document import Document
from meilisearch.models.task import TaskInfo
... | 1 | assert | numeric_literal | tests/index/test_index_document_meilisearch.py | test_get_documents_filter | 349 | null | |
meilisearch/meilisearch-python | NEW_SEARCH_CUTOFF_MS = 150
def test_get_search_cutoff_ms(empty_index):
"""Tests getting default search cutoff in ms."""
response = empty_index().get_search_cutoff_ms()
assert response is | None | assert | none_literal | tests/settings/test_settings_search_cutoff_meilisearch.py | test_get_search_cutoff_ms | 7 | null | |
meilisearch/meilisearch-python | import json
from datetime import datetime
from json import JSONEncoder
from math import ceil
from uuid import UUID, uuid4
from warnings import catch_warnings
import pytest
from meilisearch.errors import MeilisearchApiError
from meilisearch.models.document import Document
from meilisearch.models.task import TaskInfo
... | 20 | assert | numeric_literal | tests/index/test_index_document_meilisearch.py | test_get_documents_populated | 238 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.task import TaskInfo
from tests import common
def test_get_tasks_default(client):
"""Tests getting the global tasks list."""
tasks = client.get_tasks()
assert len(tasks.results) >= | 1 | assert | numeric_literal | tests/client/test_client_task_meilisearch.py | test_get_tasks_default | 12 | null | |
meilisearch/meilisearch-python | NEW_SEARCHABLE_ATTRIBUTES = ["something", "random"]
def test_get_searchable_attributes(empty_index, small_movies):
"""Tests getting the searchable attributes on an empty and populated index."""
index = empty_index()
response = index.get_searchable_attributes()
assert response == | ["*"] | assert | collection | tests/settings/test_settings_searchable_attributes_meilisearch.py | test_get_searchable_attributes | 10 | null | |
meilisearch/meilisearch-python | from datetime import datetime, timezone
import pytest
from meilisearch._utils import is_pydantic_2, iso_to_date_time
def test_iso_to_date_time_invalid_format():
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_utils.py | test_iso_to_date_time_invalid_format | 32 | null | |
meilisearch/meilisearch-python | from meilisearch.models.index import TypoTolerance
DEFAULT_TYPO_TOLERANCE = {
"enabled": True,
"disableOnNumbers": False,
"minWordSizeForTypos": {
"oneTypo": 5,
"twoTypos": 9,
},
"disableOnWords": [],
"disableOnAttributes": [],
}
NEW_TYPO_TOLERANCE = {
"enabled": True,
... | response_get.model_dump(by_alias=True) | assert | func_call | tests/settings/test_settings_typo_tolerance_meilisearch.py | test_update_typo_tolerance | 42 | null | |
meilisearch/meilisearch-python | NEW_SEPARATOR_TOKENS = ["|", "…"]
NEW_NON_SEPARATOR_TOKENS = ["@", "#"]
def test_update_separator_tokens(empty_index):
"""Tests updating the separator tokens."""
index = empty_index()
task = index.update_separator_tokens(NEW_SEPARATOR_TOKENS)
task = index.wait_for_task(task.task_uid)
assert ... | separator_tokens | assert | variable | tests/settings/test_settings_text_separators_meilisearch.py | test_update_separator_tokens | 26 | null | |
meilisearch/meilisearch-python | import base64
import json
import os
from pathlib import Path
import pytest
import requests
from meilisearch import Client
from meilisearch.errors import MeilisearchApiError
from tests import common
VOYAGE_API_KEY = os.getenv("VOYAGE_API_KEY")
INDEX_UID = "multi-modal-search-test"
EMBEDDER_NAME = "multimodal"
DATAS... | len( MOVIES ) | assert | func_call | tests/client/test_multimodal.py | setup_index | TestMultimodalSearch | 217 | null |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_create_chat_completion_http_error_propagated(client):
"""Test that HTTP errors from post_stream are properly propagated."""
with patch.object(client.http, "... | MeilisearchApiError, match="API Error") | pytest.raises | complex_expr | tests/client/test_chat_completions.py | test_create_chat_completion_http_error_propagated | 92 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.index import Faceting
DEFAULT_MAX_VALUE_PER_FACET = 100
DEFAULT_SORT_FACET_VALUES_BY = {"*": "alpha"}
NEW_MAX_VALUE_PER_FACET = {"maxValuesPerFacet": 200}
def test_reset_faceting(empty_index):
index = empty_index()
response = index.update_faceting_settings(
{"max... | Faceting( max_values_per_facet=DEFAULT_MAX_VALUE_PER_FACET, sort_facet_values_by=DEFAULT_SORT_FACET_VALUES_BY, ) | assert | func_call | tests/settings/test_setting_faceting.py | test_reset_faceting | 78 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.task import Task, TaskResults
from tests import common
def test_get_tasks(empty_index, small_movies):
"""Tests getting the tasks list of a populated index."""
index = empty_index("test_task")
current_tasks = index.get_tasks()
pre_count = len(current_tasks.results)... | None | assert | none_literal | tests/index/test_index_task_meilisearch.py | test_get_tasks | 23 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.client import Client
from meilisearch.errors import MeilisearchApiError
from meilisearch.index import Index
from tests import BASE_URL, MASTER_KEY, common
@pytest.mark.usefixtures("indexes_sample")
def test_delete_index_by_client(client):
"""Tests dele... | 0 | assert | numeric_literal | tests/index/test_index.py | test_delete_index_by_client | 203 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.embedders import OpenAiEmbedder, UserProvidedEmbedder
def new_settings(new_embedders):
return {
"rankingRules": ["typo", "words"],
"searchableAttributes": ["title", "overview"],
"embedders": new_embedders,
}
def test_update_settings(new_settings, ... | "succeeded" | assert | string_literal | tests/settings/test_settings.py | test_update_settings | 57 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
def test_swap_indexes(client, empty_index):
"""Tests swap two indexes."""
indexA = empty_index("index_A")
indexB = empty_index("index_B")
taskA = indexA.add_documents([{"id": 1, "title": "index_A"}])
taskB = indexB.add_documents([{"i... | indexB.uid | assert | complex_expr | tests/client/test_client_swap_meilisearch.py | test_swap_indexes | 27 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchApiError
from tests import common
def test_get_keys_default(client):
"""Tests if default keys have been generated and can be retrieved."""
keys = client.get_keys()
assert len(keys.results) >= 2
key_names = {key.nam... | key_names | assert | variable | tests/client/test_client_key_meilisearch.py | test_get_keys_default | 16 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
def test_swap_indexes_with_itself(client, empty_index):
"""Tests swap indexes with itself."""
index = empty_index()
with pytest.raises( | MeilisearchApiError) | pytest.raises | variable | tests/client/test_client_swap_meilisearch.py | test_swap_indexes_with_itself | 66 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
from tests.common import INDEX_UID, REMOTE_MS_1, REMOTE_MS_2
from tests.test_utils import reset_network_config
def test_basic_multi_search(client, empty_index):
"""Tests multi-search on two indexes."""
empty_index("indexA")
empty_index("inde... | "indexA" | assert | string_literal | tests/client/test_client_multi_search_meilisearch.py | test_basic_multi_search | 17 | null | |
meilisearch/meilisearch-python | NEW_DISTINCT_ATTRIBUTE = "title"
DEFAULT_DISTINCT_ATTRIBUTE = None
def test_update_distinct_attribute(empty_index):
"""Tests updating a custom distinct attribute."""
index = empty_index()
response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE)
index.wait_for_task(response.task_uid)
respo... | NEW_DISTINCT_ATTRIBUTE | assert | variable | tests/settings/test_settings_distinct_attribute_meilisearch.py | test_update_distinct_attribute | 17 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
import meilisearch
from meilisearch.errors import MeilisearchCommunicationError
from tests import MASTER_KEY
@patch("requests.post")
def test_meilisearch_communication_error_no_protocol(mock_post):
mock_post.configure_mock(__name__="post")
mock_po... | MeilisearchCommunicationError, match="no scheme/protocol supplied.") | pytest.raises | complex_expr | tests/errors/test_communication_error_meilisearch.py | test_meilisearch_communication_error_no_protocol | 27 | null | |
meilisearch/meilisearch-python | from typing import List
from meilisearch.models.index import LocalizedAttributes
NEW_LOCALIZED_ATTRIBUTES = [{"attributePatterns": ["title"], "locales": ["eng"]}]
def unpack_loc_attrs_response(response: List[LocalizedAttributes]):
return [loc_attrs.model_dump(by_alias=True) for loc_attrs in response]
def test_g... | None | assert | none_literal | tests/settings/test_settings_localized_attributes_meilisearch.py | test_get_localized_attributes | 15 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_update_chat_workspace_settings(client):
"""Test basic update_chat_workspace_settings functionality."""
mock_response = {"model": "gpt-4-turbo", "temperature... | "chats/my-workspace/settings") | assert_* | string_literal | tests/client/test_chat_completions.py | test_update_chat_workspace_settings | 128 | null | |
meilisearch/meilisearch-python | NEW_SYNONYMS = {"hp": ["harry potter"]}
def test_update_synonyms(empty_index):
"""Tests updating synonyms."""
index = empty_index()
response = index.update_synonyms(NEW_SYNONYMS)
update = index.wait_for_task(response.task_uid)
assert update.status == "succeeded"
response = index.get_synonyms()
... | response | assert | variable | tests/settings/test_settings_synonyms_meilisearch.py | test_update_synonyms | 18 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
def test_swap_indexes(client, empty_index):
"""Tests swap two indexes."""
indexA = empty_index("index_A")
indexB = empty_index("index_B")
taskA = indexA.add_documents([{"id": 1, "title": "index_A"}])
taskB = indexB.add_documents([{"i... | "indexSwap" | assert | string_literal | tests/client/test_client_swap_meilisearch.py | test_swap_indexes | 29 | null | |
meilisearch/meilisearch-python | DISPLAYED_ATTRIBUTES = ["id", "release_date", "title", "poster", "overview", "genre"]
def test_update_displayed_attributes_to_none(empty_index):
"""Tests updating the displayed attributes at null."""
index = empty_index()
# Update the settings first
response = index.update_displayed_attributes(DISPLAYE... | "succeeded" | assert | string_literal | tests/settings/test_settings_displayed_attributes_meilisearch.py | test_update_displayed_attributes_to_none | 34 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.embedders import (
CompositeEmbedder,
HuggingFaceEmbedder,
OpenAiEmbedder,
PoolingType,
UserProvidedEmbedder,
)
def test_openai_embedder_format(empty_index):
"""Tests that OpenAi embedder has the required fields and proper format."""
index = empty_inde... | 1536 | assert | numeric_literal | tests/settings/test_settings_embedders.py | test_openai_embedder_format | 75 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
def test_swap_indexes(client, empty_index):
"""Tests swap two indexes."""
indexA = empty_index("index_A")
indexB = empty_index("index_B")
taskA = indexA.add_documents([{"id": 1, "title": "index_A"}])
taskB = indexB.add_documents([{"i... | task.details | assert | complex_expr | tests/client/test_client_swap_meilisearch.py | test_swap_indexes | 30 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.task import Task, TaskResults
from tests import common
def test_get_task_inexistent(empty_index):
"""Tests getting a task of an inexistent operation."""
with pytest.raises( | Exception) | pytest.raises | variable | tests/index/test_index_task_meilisearch.py | test_get_task_inexistent | 73 | null | |
meilisearch/meilisearch-python | from meilisearch.models.index import TypoTolerance
DEFAULT_TYPO_TOLERANCE = {
"enabled": True,
"disableOnNumbers": False,
"minWordSizeForTypos": {
"oneTypo": 5,
"twoTypos": 9,
},
"disableOnWords": [],
"disableOnAttributes": [],
}
NEW_TYPO_TOLERANCE = {
"enabled": True,
... | DEFAULT_TYPO_TOLERANCE | assert | variable | tests/settings/test_settings_typo_tolerance_meilisearch.py | test_get_typo_tolerance_default | 30 | null | |
meilisearch/meilisearch-python | import datetime
from copy import deepcopy
import pytest
import meilisearch
from meilisearch.errors import MeilisearchApiError
from tests import BASE_URL
def test_generate_tenant_token_with_search_rules(get_private_key, index_with_documents):
"""Tests create a tenant token with only search rules."""
index_wit... | 5 | assert | numeric_literal | tests/client/test_client_tenant_token.py | test_generate_tenant_token_with_search_rules | 23 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchApiError
from tests import common
def test_delete_key(client, test_key):
"""Tests deleting a key."""
resp = client.delete_key(test_key.key)
assert resp == | 204 | assert | numeric_literal | tests/client/test_client_key_meilisearch.py | test_delete_key | 115 | null | |
meilisearch/meilisearch-python | import json
from datetime import datetime
from json import JSONEncoder
from math import ceil
from uuid import UUID, uuid4
from warnings import catch_warnings
import pytest
from meilisearch.errors import MeilisearchApiError
from meilisearch.models.document import Document
from meilisearch.models.task import TaskInfo
... | "id" | assert | string_literal | tests/index/test_index_document_meilisearch.py | test_add_documents | 40 | null | |
meilisearch/meilisearch-python | import json
from datetime import datetime
from json import JSONEncoder
from math import ceil
from uuid import UUID, uuid4
from warnings import catch_warnings
import pytest
from meilisearch.errors import MeilisearchApiError
from meilisearch.models.document import Document
from meilisearch.models.task import TaskInfo
... | None | assert | none_literal | tests/index/test_index_document_meilisearch.py | test_add_documents | 38 | null | |
meilisearch/meilisearch-python | import pytest
@pytest.mark.usefixtures("indexes_sample")
def test_get_all_stats(client):
"""Tests getting all stats."""
response = client.get_all_stats()
assert isinstance(response, dict)
assert "databaseSize" in response
assert isinstance(response["databaseSize"], int)
assert "lastUpdate" in r... | response["indexes"] | assert | complex_expr | tests/client/test_client_stats_meilisearch.py | test_get_all_stats | 13 | null | |
meilisearch/meilisearch-python | import pytest
import meilisearch
from tests import BASE_URL, MASTER_KEY
def test_client_timeout_not_set():
default_timeout = None
client = meilisearch.Client(BASE_URL, MASTER_KEY)
response = client.health()
assert client.config.timeout == | default_timeout | assert | variable | tests/client/test_client.py | test_client_timeout_not_set | 29 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchTimeoutError
from meilisearch.models.task import Task
def test_wait_for_task_interval_custom(index_with_documents, small_movies):
"""Tests call to wait for an update with custom interval."""
index = index_with_documents()
... | "enqueued" | assert | string_literal | tests/index/test_index_wait_for_task.py | test_wait_for_task_interval_custom | 38 | null | |
meilisearch/meilisearch-python | from meilisearch._httprequests import HttpRequests
from meilisearch.config import Config
from meilisearch.version import qualified_version
from tests import BASE_URL, MASTER_KEY
def test_get_headers_with_multiple_user_agent():
"""Tests getting defined headers from instance in HttpRequests."""
config = Config(
... | qualified_version() + ";Meilisearch Package1 (v1.1.1);Meilisearch Package2 (v2.2.2)" | assert | func_call | tests/client/test_http_requests.py | test_get_headers_with_multiple_user_agent | 27 | null | |
meilisearch/meilisearch-python | import meilisearch
def test_health(client):
"""Tests checking the health of the Meilisearch instance."""
response = client.health()
assert response["status"] == | "available" | assert | string_literal | tests/client/test_client_health_meilisearch.py | test_health | 7 | null | |
meilisearch/meilisearch-python | def test_snapshot_creation(client, index_with_documents):
"""Tests the creation of a Meilisearch snapshot."""
index_with_documents("indexUID-snapshot-creation")
snapshot = client.create_snapshot()
client.wait_for_task(snapshot.task_uid)
snapshot_status = client.get_task(snapshot.task_uid)
asser... | "succeeded" | assert | string_literal | tests/client/test_clinet_snapshots.py | test_snapshot_creation | 10 | null | |
meilisearch/meilisearch-python | import pytest
@pytest.mark.usefixtures("indexes_sample")
def test_get_all_stats(client):
"""Tests getting all stats."""
response = client.get_all_stats()
assert isinstance(response, dict)
assert "databaseSize" in | response | assert | variable | tests/client/test_client_stats_meilisearch.py | test_get_all_stats | 9 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_create_chat_completion_basic_stream(client):
"""Test basic streaming functionality with successful response."""
dummy_lines = [
b'data: {"id":"chatc... | "chats/my-assistant/chat/completions") | assert_* | string_literal | tests/client/test_chat_completions.py | test_create_chat_completion_basic_stream | 49 | null | |
meilisearch/meilisearch-python | import pytest
from tests.common import BASE_URL, REMOTE_MS_1
from tests.test_utils import reset_network_config
@pytest.mark.usefixtures("enable_network_options")
def test_update_and_get_network_settings(client):
"""Test updating and getting network settings."""
instance_name = REMOTE_MS_1
options = {
... | options["self"] | assert | complex_expr | tests/client/test_client_sharding.py | test_update_and_get_network_settings | 25 | null | |
meilisearch/meilisearch-python | DISPLAYED_ATTRIBUTES = ["id", "release_date", "title", "poster", "overview", "genre"]
def test_update_displayed_attributes(empty_index):
"""Tests updating the displayed attributes."""
index = empty_index()
response = index.update_displayed_attributes(DISPLAYED_ATTRIBUTES)
index.wait_for_task(response.t... | len(DISPLAYED_ATTRIBUTES) | assert | func_call | tests/settings/test_settings_displayed_attributes_meilisearch.py | test_update_displayed_attributes | 23 | null | |
meilisearch/meilisearch-python | NEW_SEPARATOR_TOKENS = ["|", "…"]
NEW_NON_SEPARATOR_TOKENS = ["@", "#"]
def test_get_separator_tokens_default(empty_index):
"""Tests getting the default value of separator tokens."""
separator_tokens = empty_index().get_separator_tokens()
assert separator_tokens == | [] | assert | collection | tests/settings/test_settings_text_separators_meilisearch.py | test_get_separator_tokens_default | 8 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchTimeoutError
from meilisearch.models.task import Task
def test_wait_for_task_timeout(index_with_documents):
"""Tests timeout risen by waiting for an update."""
with pytest.raises( | MeilisearchTimeoutError) | pytest.raises | variable | tests/index/test_index_wait_for_task.py | test_wait_for_task_timeout | 24 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.index import Faceting
DEFAULT_MAX_VALUE_PER_FACET = 100
DEFAULT_SORT_FACET_VALUES_BY = {"*": "alpha"}
NEW_MAX_VALUE_PER_FACET = {"maxValuesPerFacet": 200}
@pytest.mark.parametrize(
"index_name, facet_order, max_values_per_facet, expected",
[
("*", "alpha", 17, {"... | expected | assert | variable | tests/settings/test_setting_faceting.py | test_update_faceting_sort_facet_values | 66 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.document import Document
def test_iter():
document = Document({"field1": "test 1", "field2": "test 2"})
assert list(iter(document)) == | [("field1", "test 1"), ("field2", "test 2")] | assert | collection | tests/models/test_document.py | test_iter | 28 | null | |
meilisearch/meilisearch-python | from datetime import datetime
import pytest
from meilisearch.errors import MeilisearchTimeoutError
from meilisearch.models.task import Task
def test_wait_for_task_default(index_with_documents):
"""Tests waiting for an update with default parameters."""
index = index_with_documents()
response = index.add_... | ("enqueued", "processing") | assert | collection | tests/index/test_index_wait_for_task.py | test_wait_for_task_default | 19 | null | |
meilisearch/meilisearch-python | import json
from datetime import datetime
from json import JSONEncoder
from math import ceil
from uuid import UUID, uuid4
from warnings import catch_warnings
import pytest
from meilisearch.errors import MeilisearchApiError
from meilisearch.models.document import Document
from meilisearch.models.task import TaskInfo
... | "" | assert | string_literal | tests/index/test_index_document_meilisearch.py | test_update_documents | 400 | null | |
meilisearch/meilisearch-python | import pytest
import meilisearch
from tests import BASE_URL, MASTER_KEY
def test_client_timeout_set():
timeout = 5
client = meilisearch.Client(BASE_URL, MASTER_KEY, timeout=timeout)
response = client.health()
assert client.config.timeout == | timeout | assert | variable | tests/client/test_client.py | test_client_timeout_set | 21 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
import meilisearch
from meilisearch.errors import MeilisearchApiError, version_error_hint_message
from tests import BASE_URL, MASTER_KEY
def test_version_error_hint_message():
mock_response = requests.models.Response()
mock_response.status_code = ... | MeilisearchApiError) | pytest.raises | variable | tests/errors/test_api_error_meilisearch.py | test_version_error_hint_message | 47 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_create_chat_completion_basic_stream(client):
"""Test basic streaming functionality with successful response."""
dummy_lines = [
b'data: {"id":"chatc... | "Hello" | assert | string_literal | tests/client/test_chat_completions.py | test_create_chat_completion_basic_stream | 56 | null | |
meilisearch/meilisearch-python | NEW_STOP_WORDS = ["of", "the"]
def test_update_stop_words(empty_index):
"""Tests updating the stop words."""
index = empty_index()
response = index.update_stop_words(NEW_STOP_WORDS)
update = index.wait_for_task(response.task_uid)
assert update.status == "succeeded"
response = index.get_stop_wor... | response | assert | variable | tests/settings/test_settings_stop_words_meilisearch.py | test_update_stop_words | 18 | null | |
meilisearch/meilisearch-python | import pytest
import meilisearch
from tests import BASE_URL, MASTER_KEY
@pytest.mark.parametrize(
"api_key, custom_headers, expected",
(
("testKey", None, {"Authorization": "Bearer testKey"}),
(
"testKey",
{"header_key_1": "header_value_1", "header_key_2": "header_value... | expected.items() | assert | func_call | tests/client/test_client.py | test_headers | 60 | null | |
meilisearch/meilisearch-python | import json
from datetime import datetime
from json import JSONEncoder
from math import ceil
from uuid import UUID, uuid4
from warnings import catch_warnings
import pytest
from meilisearch.errors import MeilisearchApiError
from meilisearch.models.document import Document
from meilisearch.models.task import TaskInfo
... | [] | assert | collection | tests/index/test_index_document_meilisearch.py | test_get_documents_default | 30 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.task import Task, TaskResults
from tests import common
def test_get_tasks(empty_index, small_movies):
"""Tests getting the tasks list of a populated index."""
index = empty_index("test_task")
current_tasks = index.get_tasks()
pre_count = len(current_tasks.results)... | pre_count + 1 | assert | complex_expr | tests/index/test_index_task_meilisearch.py | test_get_tasks | 26 | null | |
meilisearch/meilisearch-python | from meilisearch.models.index import ProximityPrecision
NEW_PROXIMITY_PRECISION = ProximityPrecision.BY_ATTRIBUTE
def test_update_proximity_precision(empty_index):
"""Tests updating proximity precision."""
index = empty_index()
response = index.update_proximity_precision(NEW_PROXIMITY_PRECISION)
updat... | response | assert | variable | tests/settings/test_settings_proximity_precision_meilisearch.py | test_update_proximity_precision | 19 | null | |
meilisearch/meilisearch-python | from unittest.mock import patch
import pytest
import requests
from meilisearch.errors import MeilisearchApiError, MeilisearchCommunicationError
def test_create_chat_completion_basic_stream(client):
"""Test basic streaming functionality with successful response."""
dummy_lines = [
b'data: {"id":"chatc... | 2 | assert | numeric_literal | tests/client/test_chat_completions.py | test_create_chat_completion_basic_stream | 55 | null | |
meilisearch/meilisearch-python | import datetime
from copy import deepcopy
import pytest
import meilisearch
from meilisearch.errors import MeilisearchApiError
from tests import BASE_URL
def test_generate_tenant_token_with_search_rules_on_one_index(get_private_key, empty_index):
"""Tests create a tenant token with search rules set for one index.... | MeilisearchApiError) | pytest.raises | variable | tests/client/test_client_tenant_token.py | test_generate_tenant_token_with_search_rules_on_one_index | 39 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.embedders import OpenAiEmbedder, UserProvidedEmbedder
def new_settings(new_embedders):
return {
"rankingRules": ["typo", "words"],
"searchableAttributes": ["title", "overview"],
"embedders": new_embedders,
}
def test_get_settings_default(empty_ind... | [] | assert | collection | tests/settings/test_settings.py | test_get_settings_default | 48 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.errors import MeilisearchApiError
def test_update_webhook(client):
"""Test updating a webhook."""
# Create a webhook first
webhook_data = {
"url": "https://example.com/webhook",
}
created_webhook = client.create_webhook(webhook_data)
# Update the webhoo... | update_data["url"] | assert | complex_expr | tests/client/test_client_webhooks_meilisearch.py | test_update_webhook | 72 | null | |
meilisearch/meilisearch-python | NEW_SEARCHABLE_ATTRIBUTES = ["something", "random"]
def test_update_searchable_attributes_to_none(empty_index):
"""Tests updating the searchable attributes at null."""
index = empty_index()
# Update the settings first
response = index.update_searchable_attributes(NEW_SEARCHABLE_ATTRIBUTES)
update =... | "succeeded" | assert | string_literal | tests/settings/test_settings_searchable_attributes_meilisearch.py | test_update_searchable_attributes_to_none | 34 | null | |
meilisearch/meilisearch-python | NEW_RANKING_RULES = ["typo", "exactness"]
DEFAULT_RANKING_RULES = [
"words",
"typo",
"proximity",
"attributeRank",
"sort",
"wordPosition",
"exactness",
]
def test_update_ranking_rules_none(empty_index):
"""Tests updating the ranking rules at null."""
index = empty_index()
# Upda... | response | assert | variable | tests/settings/test_settings_ranking_rules_meilisearch.py | test_update_ranking_rules_none | 40 | null | |
meilisearch/meilisearch-python | from meilisearch._httprequests import HttpRequests
from meilisearch.config import Config
from meilisearch.version import qualified_version
from tests import BASE_URL, MASTER_KEY
def test_get_headers_from_http_requests_instance():
"""Tests getting defined headers from instance in HttpRequests."""
config = Confi... | qualified_version() | assert | func_call | tests/client/test_http_requests.py | test_get_headers_from_http_requests_instance | 13 | null | |
meilisearch/meilisearch-python | from datetime import datetime, timezone
import pytest
from meilisearch._utils import is_pydantic_2, iso_to_date_time
def test_is_pydantic_2():
assert is_pydantic_2() is | True | assert | bool_literal | tests/test_utils.py | test_is_pydantic_2 | 9 | null | |
meilisearch/meilisearch-python | import pytest
from meilisearch.models.task import TaskInfo
from tests import common
def test_get_task(client):
"""Tests getting the tasks list of an empty index."""
response = client.create_index(uid=common.INDEX_UID)
client.wait_for_task(response.task_uid)
task = client.get_task(response.task_uid)
... | task_dict | assert | variable | tests/client/test_client_task_meilisearch.py | test_get_task | 72 | null | |
meilisearch/meilisearch-python | NEW_SEARCHABLE_ATTRIBUTES = ["something", "random"]
def test_update_searchable_attributes(empty_index):
"""Tests updating the searchable attributes."""
index = empty_index()
response = index.update_searchable_attributes(NEW_SEARCHABLE_ATTRIBUTES)
index.wait_for_task(response.task_uid)
response = in... | len(NEW_SEARCHABLE_ATTRIBUTES) | assert | func_call | tests/settings/test_settings_searchable_attributes_meilisearch.py | test_update_searchable_attributes | 23 | null | |
meilisearch/meilisearch-python | def test_snapshot_creation(client, index_with_documents):
"""Tests the creation of a Meilisearch snapshot."""
index_with_documents("indexUID-snapshot-creation")
snapshot = client.create_snapshot()
client.wait_for_task(snapshot.task_uid)
snapshot_status = client.get_task(snapshot.task_uid)
assert... | "snapshotCreation" | assert | string_literal | tests/client/test_clinet_snapshots.py | test_snapshot_creation | 11 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.