1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Tests for query analyzer creation.
10 from pathlib import Path
14 from nominatim_api.search.query_analyzer_factory import make_query_analyzer
15 from nominatim_api.search.icu_tokenizer import ICUQueryAnalyzer
18 async def test_import_icu_tokenizer(table_factory, api):
19 table_factory('nominatim_properties',
20 definition='property TEXT, value TEXT',
21 content=(('tokenizer', 'icu'),
22 ('tokenizer_import_normalisation', ':: lower();'),
23 ('tokenizer_import_transliteration', "'1' > '/1/'; 'ä' > 'ä '")))
25 async with api.begin() as conn:
26 ana = await make_query_analyzer(conn)
28 assert isinstance(ana, ICUQueryAnalyzer)
32 async def test_import_missing_property(table_factory, api):
33 table_factory('nominatim_properties',
34 definition='property TEXT, value TEXT')
36 async with api.begin() as conn:
37 with pytest.raises(ValueError, match='Property.*not found'):
38 await make_query_analyzer(conn)
42 async def test_import_missing_module(table_factory, api):
43 table_factory('nominatim_properties',
44 definition='property TEXT, value TEXT',
45 content=(('tokenizer', 'missing'),))
47 async with api.begin() as conn:
48 with pytest.raises(RuntimeError, match='Tokenizer not found'):
49 await make_query_analyzer(conn)