|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | import json |
6 | | -from types import SimpleNamespace |
7 | 6 |
|
8 | 7 | import pytest |
9 | 8 |
|
10 | 9 | from api.error_codes import ErrorCode |
| 10 | +from api.search import _IndexSearchOutcome |
11 | 11 | from tests.conftest import assert_error_response |
12 | 12 |
|
13 | 13 |
|
@@ -79,18 +79,16 @@ def test_bulk_export_empty_includes_export_nothing_code(client_empty): |
79 | 79 |
|
80 | 80 |
|
81 | 81 | def test_search_index_unavailable_code(client_single, monkeypatch): |
| 82 | + def _raise_live_scan_failure(*_args, **_kwargs): |
| 83 | + raise RuntimeError("live scan failed") |
| 84 | + |
82 | 85 | monkeypatch.setattr( |
83 | 86 | "api.search._search_via_index", |
84 | | - lambda *_args, **_kwargs: SimpleNamespace( |
85 | | - hits=None, |
86 | | - fts_exhausted=False, |
87 | | - index_locked_without_hits=True, |
| 87 | + lambda *_args, **_kwargs: _IndexSearchOutcome( |
| 88 | + None, False, index_locked_without_hits=True |
88 | 89 | ), |
89 | 90 | ) |
90 | | - monkeypatch.setattr( |
91 | | - "api.search._search_live_scan", |
92 | | - lambda *_args, **_kwargs: (_ for _ in ()).throw(RuntimeError("live scan failed")), |
93 | | - ) |
| 91 | + monkeypatch.setattr("api.search._search_live_scan", _raise_live_scan_failure) |
94 | 92 | resp = client_single.get("/api/search?q=test") |
95 | 93 | assert resp.status_code == 503 |
96 | 94 | body_text = json.dumps(resp.get_json()) |
|
0 commit comments