2 Test for tiger data function
4 from pathlib import Path
9 from nominatim.tools import tiger_data, database_import
12 @pytest.mark.parametrize("threads", (1, 5))
13 def test_add_tiger_data(dsn, src_dir, def_config, monkeypatch,tmp_path,
14 temp_db_cursor, threads, temp_db):
15 monkeypatch.setenv('NOMINATIM_DATABASE_MODULE_PATH', '.')
16 temp_db_cursor.execute('CREATE EXTENSION hstore')
17 temp_db_cursor.execute('CREATE EXTENSION postgis')
18 temp_db_cursor.execute('CREATE TABLE place (id INT)')
20 database_import.import_base_data('dbname=' + temp_db, src_dir / 'data',
21 ignore_partitions=False)
22 sqlfile = tmp_path / '1010.sql'
23 sqlfile.write_text("""INSERT INTO place values (1)""")
24 tiger_data.add_tiger_data(dsn, str(tmp_path), threads, def_config, src_dir / 'lib-sql')
26 assert temp_db_cursor.table_rows('place') == 1
28 @pytest.mark.parametrize("threads", (1, 5))
29 def test_add_tiger_data_tarfile(dsn, src_dir, def_config, monkeypatch,tmp_path,
30 temp_db_cursor, threads, temp_db):
31 monkeypatch.setenv('NOMINATIM_DATABASE_MODULE_PATH', '.')
32 temp_db_cursor.execute('CREATE EXTENSION hstore')
33 temp_db_cursor.execute('CREATE EXTENSION postgis')
34 temp_db_cursor.execute('CREATE TABLE place (id INT)')
36 database_import.import_base_data('dbname=' + temp_db, src_dir / 'data',
37 ignore_partitions=False)
38 sqlfile = tmp_path / '1010.sql'
39 sqlfile.write_text("""INSERT INTO place values (1)""")
40 tar = tarfile.open("sample.tar.gz", "w:gz")
43 tiger_data.add_tiger_data(dsn, str(src_dir / 'sample.tar.gz'), threads, def_config, src_dir / 'lib-sql')
45 assert temp_db_cursor.table_rows('place') == 1