]> git.openstreetmap.org Git - nominatim.git/blob - test/python/api/test_warm.py
Merge pull request #3190 from lonvia/fix-internal-server-errors
[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) 2023 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.cli
13
14 @pytest.fixture(autouse=True)
15 def setup_database_with_context(apiobj, table_factory):
16     table_factory('word',
17                   definition='word_id INT, word_token TEXT, type TEXT, word TEXT, info JSONB',
18                   content=[(55, 'test', 'W', 'test', None),
19                            (2, 'test', 'w', 'test', None)])
20
21     apiobj.add_data('properties',
22                     [{'property': 'tokenizer', 'value': 'icu'},
23                      {'property': 'tokenizer_import_normalisation', 'value': ':: lower();'},
24                      {'property': 'tokenizer_import_transliteration', 'value': "'1' > '/1/'; 'ä' > 'ä '"},
25                     ])
26
27
28 @pytest.mark.parametrize('args', [['--search-only'], ['--reverse-only']])
29 def test_warm_all(tmp_path, args):
30     assert 0 == nominatim.cli.nominatim(module_dir='MODULE NOT AVAILABLE',
31                                         osm2pgsql_path='OSM2PGSQL NOT AVAILABLE',
32                                         cli_args=['admin', '--project-dir', str(tmp_path),
33                                                   '--warm'] + args)