2 Tests for freeze functions (removing unused database parts).
 
   4 from nominatim.tools import freeze
 
   6 NOMINATIM_RUNTIME_TABLES = [
 
   7     'country_name', 'country_osm_grid',
 
   8     'location_postcode', 'location_property_osmline', 'location_property_tiger',
 
   9     'placex', 'place_adressline',
 
  14 NOMINATIM_DROP_TABLES = [
 
  16     'location_area', 'location_area_country', 'location_area_large_100',
 
  18     'place', 'planet_osm_nodes', 'planet_osm_rels', 'planet_osm_ways',
 
  20     'wikipedia_article', 'wikipedia_redirect'
 
  23 def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
 
  24     for table in NOMINATIM_RUNTIME_TABLES + NOMINATIM_DROP_TABLES:
 
  27     freeze.drop_update_tables(temp_db_conn)
 
  29     for table in NOMINATIM_RUNTIME_TABLES:
 
  30         assert temp_db_cursor.table_exists(table)
 
  32     for table in NOMINATIM_DROP_TABLES:
 
  33         assert not temp_db_cursor.table_exists(table)
 
  35 def test_drop_flatnode_file_no_file():
 
  36     freeze.drop_flatnode_file('')
 
  39 def test_drop_flatnode_file_file_already_gone(tmp_path):
 
  40     freeze.drop_flatnode_file(str(tmp_path / 'something.store'))
 
  43 def test_drop_flatnode_file_delte(tmp_path):
 
  44     flatfile = tmp_path / 'flatnode.store'
 
  45     flatfile.write_text('Some content')
 
  47     freeze.drop_flatnode_file(str(flatfile))
 
  49     assert not flatfile.exists()