|
2 | 2 | import json |
3 | 3 | from typing import Optional |
4 | 4 |
|
| 5 | +import requests |
5 | 6 | from pytest import fixture |
6 | 7 |
|
7 | 8 | import meilisearch |
@@ -205,13 +206,68 @@ def test_key_info(client): |
205 | 206 | pass |
206 | 207 |
|
207 | 208 |
|
| 209 | +@fixture(scope="function") |
| 210 | +def test_nondescript_key_info(client): |
| 211 | + key_info = { |
| 212 | + "name": "keyWithoutDescription", |
| 213 | + "actions": ["search"], |
| 214 | + "indexes": [common.INDEX_UID], |
| 215 | + "expiresAt": None, |
| 216 | + } |
| 217 | + |
| 218 | + yield key_info |
| 219 | + |
| 220 | + try: |
| 221 | + keys = client.get_keys().results |
| 222 | + key = next(x for x in keys if x.name == key_info["name"]) |
| 223 | + client.delete_key(key.key) |
| 224 | + except MeilisearchApiError: |
| 225 | + pass |
| 226 | + except StopIteration: |
| 227 | + pass |
| 228 | + |
| 229 | + |
208 | 230 | @fixture(scope="function") |
209 | 231 | def get_private_key(client): |
210 | 232 | keys = client.get_keys().results |
211 | 233 | key = next(x for x in keys if "Default Search API" in x.name) |
212 | 234 | return key |
213 | 235 |
|
214 | 236 |
|
| 237 | +@fixture |
| 238 | +def enable_vector_search(): |
| 239 | + requests.patch( |
| 240 | + f"{common.BASE_URL}/experimental-features", |
| 241 | + headers={"Authorization": f"Bearer {common.MASTER_KEY}"}, |
| 242 | + json={"vectorStore": True}, |
| 243 | + timeout=10, |
| 244 | + ) |
| 245 | + yield |
| 246 | + requests.patch( |
| 247 | + f"{common.BASE_URL}/experimental-features", |
| 248 | + headers={"Authorization": f"Bearer {common.MASTER_KEY}"}, |
| 249 | + json={"vectorStore": False}, |
| 250 | + timeout=10, |
| 251 | + ) |
| 252 | + |
| 253 | + |
| 254 | +@fixture |
| 255 | +def enable_edit_documents_by_function(): |
| 256 | + requests.patch( |
| 257 | + f"{common.BASE_URL}/experimental-features", |
| 258 | + headers={"Authorization": f"Bearer {common.MASTER_KEY}"}, |
| 259 | + json={"editDocumentsByFunction": True}, |
| 260 | + timeout=10, |
| 261 | + ) |
| 262 | + yield |
| 263 | + requests.patch( |
| 264 | + f"{common.BASE_URL}/experimental-features", |
| 265 | + headers={"Authorization": f"Bearer {common.MASTER_KEY}"}, |
| 266 | + json={"editDocumentsByFunction": False}, |
| 267 | + timeout=10, |
| 268 | + ) |
| 269 | + |
| 270 | + |
215 | 271 | @fixture |
216 | 272 | def new_embedders(): |
217 | 273 | return { |
|
0 commit comments