2 Tests for freeze functions (removing unused database parts).
6 from nominatim.tools import freeze
8 NOMINATIM_RUNTIME_TABLES = [
9 'country_name', 'country_osm_grid',
10 'location_postcode', 'location_property_osmline', 'location_property_tiger',
11 'placex', 'place_adressline',
16 NOMINATIM_DROP_TABLES = [
18 'location_area', 'location_area_country', 'location_area_large_100',
20 'place', 'planet_osm_nodes', 'planet_osm_rels', 'planet_osm_ways',
22 'wikipedia_article', 'wikipedia_redirect'
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))
29 freeze.drop_update_tables(temp_db_conn)
31 for table in NOMINATIM_RUNTIME_TABLES:
32 assert temp_db_cursor.table_exists(table)
34 for table in NOMINATIM_DROP_TABLES:
35 assert not temp_db_cursor.table_exists(table)
37 def test_drop_flatnode_file_no_file():
38 freeze.drop_flatnode_file('')
41 def test_drop_flatnode_file_file_already_gone(tmp_path):
42 freeze.drop_flatnode_file(str(tmp_path / 'something.store'))
45 def test_drop_flatnode_file_delte(tmp_path):
46 flatfile = tmp_path / 'flatnode.store'
47 flatfile.write_text('Some content')
49 freeze.drop_flatnode_file(str(flatfile))
51 assert not flatfile.exists()