]> git.openstreetmap.org Git - nominatim.git/blob - test/python/api/test_warm.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / python / api / test_warm.py
1 # SPDX-License-Identifier: GPL-3.0-or-later
2 #
3 # This file is part of Nominatim. (https://nominatim.org)
4 #
5 # Copyright (C) 2025 by the Nominatim developer community.
6 # For a full list of authors see the git log.
7 """
8 Tests for warm-up CLI function.
9 """
10 import pytest
11
12 import nominatim_db.cli
13
14
15 @pytest.fixture(autouse=True)
16 def setup_database_with_context(apiobj, table_factory):
17     table_factory('word',
18                   definition='word_id INT, word_token TEXT, type TEXT, word TEXT, info JSONB',
19                   content=[(55, 'test', 'W', 'test', None),
20                            (2, 'test', 'w', 'test', None)])
21
22     apiobj.add_data('properties',
23                     [{'property': 'tokenizer', 'value': 'icu'},
24                      {'property': 'tokenizer_import_normalisation', 'value': ':: lower();'},
25                      {'property': 'tokenizer_import_transliteration',
26                       'value': "'1' > '/1/'; 'ä' > 'ä '"}
27                      ])
28
29
30 @pytest.mark.parametrize('args', [['--search-only'], ['--reverse-only']])
31 def test_warm_all(tmp_path, args):
32     assert 0 == nominatim_db.cli.nominatim(cli_args=['admin', '--project-dir', str(tmp_path),
33                                                      '--warm'] + args)