fix: restrict search to current editions

This commit is contained in:
2026-08-21 07:24:16 +03:00
parent 73ff287b20
commit 0bef90debd
5 changed files with 30 additions and 11 deletions

View File

@@ -47,6 +47,16 @@ class SearchApiTest(unittest.TestCase):
with self.assertRaisesRegex(ApiError, "document not found"):
api.handle("GET", "/documents/%2E%2E")
def test_filters_count_documents_and_return_bilingual_labels(self):
with tempfile.TemporaryDirectory() as temporary:
api = self.make_api(Path(temporary))
response = {"aggregations": {name: {"buckets": [{"key": ["Закон", "Мыйзам"], "documents": {"value": 3}}]} for name in ("document_types", "statuses", "authorities")}}
with patch("search.api.request_json", return_value=response) as request:
payload = api.handle("GET", "/search/filters?language=ky")[1]
self.assertEqual(payload["document_types"][0], {"code": "Мыйзам", "labels": {"ru": "Закон", "ky": "Мыйзам"}, "count": 3})
body = json.loads(request.call_args.args[2])
self.assertIn("multi_terms", body["aggs"]["document_types"])
if __name__ == "__main__":
unittest.main()