2 Test for various refresh functions.
4 from pathlib import Path
8 from nominatim.tools import refresh
10 def test_refresh_import_wikipedia_not_existing(dsn):
11 assert refresh.import_wikipedia_articles(dsn, Path('.')) == 1
14 @pytest.mark.parametrize("replace", (True, False))
15 def test_refresh_import_wikipedia(dsn, src_dir, table_factory, temp_db_cursor, replace):
17 table_factory('wikipedia_article')
18 table_factory('wikipedia_redirect')
20 # use the small wikipedia file for the API testdb
21 assert refresh.import_wikipedia_articles(dsn, src_dir / 'test' / 'testdb') == 0
23 assert temp_db_cursor.table_rows('wikipedia_article') > 0
24 assert temp_db_cursor.table_rows('wikipedia_redirect') > 0
27 def test_recompute_importance(placex_table, table_factory, temp_db_conn, temp_db_cursor):
28 temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION compute_importance(extratags HSTORE,
29 country_code varchar(2),
30 osm_type varchar(1), osm_id BIGINT,
33 AS $$ SELECT 0.1::float, 'foo'::text $$ LANGUAGE SQL""")
35 refresh.recompute_importance(temp_db_conn)