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, tmp_path, sql_preprocessor,
14 temp_db_cursor, threads, temp_db):
15 temp_db_cursor.execute('CREATE EXTENSION hstore')
16 temp_db_cursor.execute('CREATE EXTENSION postgis')
17 temp_db_cursor.execute('CREATE TABLE place (id INT)')
18 sqlfile = tmp_path / '1010.sql'
19 sqlfile.write_text("""INSERT INTO place values (1)""")
20 tiger_data.add_tiger_data(dsn, str(tmp_path), threads, def_config, src_dir / 'lib-sql')
22 assert temp_db_cursor.table_rows('place') == 1
24 @pytest.mark.parametrize("threads", (1, 5))
25 def test_add_tiger_data_tarfile(dsn, src_dir, def_config, tmp_path,
26 temp_db_cursor, threads, temp_db, sql_preprocessor):
27 temp_db_cursor.execute('CREATE EXTENSION hstore')
28 temp_db_cursor.execute('CREATE EXTENSION postgis')
29 temp_db_cursor.execute('CREATE TABLE place (id INT)')
30 sqlfile = tmp_path / '1010.sql'
31 sqlfile.write_text("""INSERT INTO place values (1)""")
32 tar = tarfile.open("sample.tar.gz", "w:gz")
35 tiger_data.add_tiger_data(dsn, str(src_dir / 'sample.tar.gz'), threads, def_config, src_dir / 'lib-sql')
37 assert temp_db_cursor.table_rows('place') == 1