mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-15 19:07:58 +00:00
organise python tests in subdirectories
The directories follow the same structure as the modules in nominatim/.
This commit is contained in:
49
test/python/tools/test_freeze.py
Normal file
49
test/python/tools/test_freeze.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
Tests for freeze functions (removing unused database parts).
|
||||
"""
|
||||
from nominatim.tools import freeze
|
||||
|
||||
NOMINATIM_RUNTIME_TABLES = [
|
||||
'country_name', 'country_osm_grid',
|
||||
'location_postcode', 'location_property_osmline', 'location_property_tiger',
|
||||
'placex', 'place_adressline',
|
||||
'search_name',
|
||||
'word'
|
||||
]
|
||||
|
||||
NOMINATIM_DROP_TABLES = [
|
||||
'address_levels',
|
||||
'location_area', 'location_area_country', 'location_area_large_100',
|
||||
'location_road_1',
|
||||
'place', 'planet_osm_nodes', 'planet_osm_rels', 'planet_osm_ways',
|
||||
'search_name_111',
|
||||
'wikipedia_article', 'wikipedia_redirect'
|
||||
]
|
||||
|
||||
def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
|
||||
for table in NOMINATIM_RUNTIME_TABLES + NOMINATIM_DROP_TABLES:
|
||||
table_factory(table)
|
||||
|
||||
freeze.drop_update_tables(temp_db_conn)
|
||||
|
||||
for table in NOMINATIM_RUNTIME_TABLES:
|
||||
assert temp_db_cursor.table_exists(table)
|
||||
|
||||
for table in NOMINATIM_DROP_TABLES:
|
||||
assert not temp_db_cursor.table_exists(table)
|
||||
|
||||
def test_drop_flatnode_file_no_file():
|
||||
freeze.drop_flatnode_file('')
|
||||
|
||||
|
||||
def test_drop_flatnode_file_file_already_gone(tmp_path):
|
||||
freeze.drop_flatnode_file(str(tmp_path / 'something.store'))
|
||||
|
||||
|
||||
def test_drop_flatnode_file_delte(tmp_path):
|
||||
flatfile = tmp_path / 'flatnode.store'
|
||||
flatfile.write_text('Some content')
|
||||
|
||||
freeze.drop_flatnode_file(str(flatfile))
|
||||
|
||||
assert not flatfile.exists()
|
||||
Reference in New Issue
Block a user