Handle unmapped source catalog values
This commit is contained in:
@@ -9,10 +9,19 @@ from contextlib import closing
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from search.catalog import legal_force_code, labels, source_code
|
||||
from search.minjust_opensearch import bulk_batches, document_codes, export_bulk, load_bulk, request_json, switch_alias
|
||||
|
||||
|
||||
class MinjustOpenSearchTest(unittest.TestCase):
|
||||
def test_unknown_document_type_keeps_source_label_and_has_no_inferred_force(self):
|
||||
value = {"ru": "Решение", "ky": "Решение"}
|
||||
|
||||
self.assertEqual(source_code("document_type", value), "other")
|
||||
self.assertEqual(labels("document_type", "other"), {"ru": "Прочие документы", "ky": "Башка документтер"})
|
||||
self.assertIsNone(legal_force_code(value))
|
||||
self.assertEqual(source_code("status", {"ru": "Не вступил в силу", "ky": "Күчүнө кире элек"}), "not_yet_effective")
|
||||
|
||||
def test_switches_alias_atomically_after_successful_load(self):
|
||||
with patch("search.minjust_opensearch.request_json", return_value={"acknowledged": True}) as request:
|
||||
switch_alias("http://127.0.0.1:9200/", "akyldash-fragments-v2", "akyldash-fragments-current")
|
||||
|
||||
Reference in New Issue
Block a user