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 freeze functions (removing unused database parts).
10 from nominatim_db.tools import freeze
12 NOMINATIM_RUNTIME_TABLES = [
13 'country_name', 'country_osm_grid',
14 'location_postcode', 'location_property_osmline', 'location_property_tiger',
15 'placex', 'place_adressline',
20 NOMINATIM_DROP_TABLES = [
22 'location_area', 'location_area_country', 'location_area_large_100',
24 'place', 'planet_osm_nodes', 'planet_osm_rels', 'planet_osm_ways',
26 'wikipedia_article', 'wikipedia_redirect'
29 def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
30 for table in NOMINATIM_RUNTIME_TABLES + NOMINATIM_DROP_TABLES:
33 assert not freeze.is_frozen(temp_db_conn)
35 freeze.drop_update_tables(temp_db_conn)
37 for table in NOMINATIM_RUNTIME_TABLES:
38 assert temp_db_cursor.table_exists(table)
40 for table in NOMINATIM_DROP_TABLES:
41 assert not temp_db_cursor.table_exists(table)
43 assert freeze.is_frozen(temp_db_conn)
45 def test_drop_flatnode_file_no_file():
46 freeze.drop_flatnode_file(None)
49 def test_drop_flatnode_file_file_already_gone(tmp_path):
50 freeze.drop_flatnode_file(tmp_path / 'something.store')
53 def test_drop_flatnode_file_delete(tmp_path):
54 flatfile = tmp_path / 'flatnode.store'
55 flatfile.write_text('Some content')
57 freeze.drop_flatnode_file(flatfile)
59 assert not flatfile.exists()