-def test_install_module_custom(tmp_path):
- (tmp_path / 'nominatim.so').write_text('TEST nomiantim.so')
-
- database_import.install_module(tmp_path, tmp_path, str(tmp_path.resolve()))
-
- assert not (tmp_path / 'module').exists()
-
-
-def test_install_module_fail_access(temp_db_conn, tmp_path):
- (tmp_path / 'nominatim.so').write_text('TEST nomiantim.so')
-
- with pytest.raises(UsageError, match='.*module cannot be accessed.*'):
- database_import.install_module(tmp_path, tmp_path, '',
- conn=temp_db_conn)
-
-
-def test_import_base_data(src_dir, temp_db, temp_db_cursor):
- temp_db_cursor.execute('CREATE EXTENSION hstore')
- temp_db_cursor.execute('CREATE EXTENSION postgis')
- database_import.import_base_data('dbname=' + temp_db, src_dir / 'data')
-
- assert temp_db_cursor.scalar('SELECT count(*) FROM country_name') > 0
-
-
-def test_import_base_data_ignore_partitions(src_dir, temp_db, temp_db_cursor):
- temp_db_cursor.execute('CREATE EXTENSION hstore')
- temp_db_cursor.execute('CREATE EXTENSION postgis')
- database_import.import_base_data('dbname=' + temp_db, src_dir / 'data',
- ignore_partitions=True)
-
- assert temp_db_cursor.scalar('SELECT count(*) FROM country_name') > 0
- assert temp_db_cursor.scalar('SELECT count(*) FROM country_name WHERE partition != 0') == 0
-
-
-def test_import_osm_data_simple(temp_db_cursor,osm2pgsql_options):
- temp_db_cursor.execute('CREATE TABLE place (id INT)')
- temp_db_cursor.execute('INSERT INTO place values (1)')