]> git.openstreetmap.org Git - nominatim.git/blob - test/python/test_tools_freeze.py
remove debug code
[nominatim.git] / test / python / test_tools_freeze.py
1 """
2 Tests for freeze functions (removing unused database parts).
3 """
4 import pytest
5
6 from nominatim.tools import freeze
7
8 NOMINATIM_RUNTIME_TABLES = [
9     'country_name', 'country_osm_grid',
10     'location_postcode', 'location_property_osmline', 'location_property_tiger',
11     'placex', 'place_adressline',
12     'search_name',
13     'word'
14 ]
15
16 NOMINATIM_DROP_TABLES = [
17     'address_levels',
18     'location_area', 'location_area_country', 'location_area_large_100',
19     'location_road_1',
20     'place', 'planet_osm_nodes', 'planet_osm_rels', 'planet_osm_ways',
21     'search_name_111',
22     'wikipedia_article', 'wikipedia_redirect'
23 ]
24
25 def test_drop_tables(temp_db_conn, temp_db_cursor):
26     for table in NOMINATIM_RUNTIME_TABLES + NOMINATIM_DROP_TABLES:
27         temp_db_cursor.execute('CREATE TABLE {} (id int)'.format(table))
28
29     freeze.drop_update_tables(temp_db_conn)
30
31     for table in NOMINATIM_RUNTIME_TABLES:
32         assert temp_db_cursor.table_exists(table)
33
34     for table in NOMINATIM_DROP_TABLES:
35         assert not temp_db_cursor.table_exists(table)
36
37 def test_drop_flatnode_file_no_file():
38     freeze.drop_flatnode_file('')
39
40
41 def test_drop_flatnode_file_file_already_gone(tmp_path):
42     freeze.drop_flatnode_file(str(tmp_path / 'something.store'))
43
44
45 def test_drop_flatnode_file_delte(tmp_path):
46     flatfile = tmp_path / 'flatnode.store'
47     flatfile.write_text('Some content')
48
49     freeze.drop_flatnode_file(str(flatfile))
50
51     assert not flatfile.exists()