]> git.openstreetmap.org Git - nominatim.git/blob - test/python/test_tools_admin.py
make word count computation part of the import
[nominatim.git] / test / python / test_tools_admin.py
1 """
2 Tests for maintenance and analysis functions.
3 """
4 import pytest
5
6 from nominatim.errors import UsageError
7 from nominatim.tools import admin
8
9 @pytest.fixture(autouse=True)
10 def create_placex_table(placex_table):
11     """ All tests in this module require the placex table to be set up.
12     """
13
14
15 def test_analyse_indexing_no_objects(temp_db_conn):
16     with pytest.raises(UsageError):
17         admin.analyse_indexing(temp_db_conn)
18
19
20 @pytest.mark.parametrize("oid", ['1234', 'N123a', 'X123'])
21 def test_analyse_indexing_bad_osmid(temp_db_conn, oid):
22     with pytest.raises(UsageError):
23         admin.analyse_indexing(temp_db_conn, osm_id=oid)
24
25
26 def test_analyse_indexing_unknown_osmid(temp_db_conn):
27     with pytest.raises(UsageError):
28         admin.analyse_indexing(temp_db_conn, osm_id='W12345674')
29
30
31 def test_analyse_indexing_with_place_id(temp_db_conn, temp_db_cursor):
32     temp_db_cursor.execute("INSERT INTO placex (place_id) VALUES(12345)")
33
34     admin.analyse_indexing(temp_db_conn, place_id=12345)
35
36
37 def test_analyse_indexing_with_osm_id(temp_db_conn, temp_db_cursor):
38     temp_db_cursor.execute("""INSERT INTO placex (place_id, osm_type, osm_id)
39                               VALUES(9988, 'N', 10000)""")
40
41     admin.analyse_indexing(temp_db_conn, osm_id='N10000')