]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/test_cli.py
Merge pull request #2321 from AntoJvlt/csv-import-special-phrases
[nominatim.git] / test / python / test_cli.py
index 4b1a4c125c7a335915b44197395430d3d27a7d02..27ea0d5dbaea84958408d3b40b0a08ccd0517171 100644 (file)
@@ -255,10 +255,27 @@ def test_index_command(mock_func_factory, temp_db_cursor, tokenizer_mock,
     assert bnd_mock.called == do_bnds
     assert rank_mock.called == do_ranks
 
-def test_special_phrases_command(temp_db, mock_func_factory, tokenizer_mock):
-    func = mock_func_factory(nominatim.clicmd.special_phrases.SpecialPhrasesImporter, 'import_from_wiki')
+@pytest.mark.parametrize("no_replace", [(True), (False)])
+def test_special_phrases_wiki_command(temp_db, mock_func_factory, tokenizer_mock, no_replace):
+    func = mock_func_factory(nominatim.clicmd.special_phrases.SPImporter, 'import_phrases')
 
-    call_nominatim('special-phrases', '--import-from-wiki')
+    if no_replace:
+        call_nominatim('special-phrases', '--import-from-wiki', '--no-replace')
+    else:
+        call_nominatim('special-phrases', '--import-from-wiki')
+
+    assert func.called == 1
+
+@pytest.mark.parametrize("no_replace", [(True), (False)])
+def test_special_phrases_csv_command(temp_db, mock_func_factory, tokenizer_mock, no_replace):
+    func = mock_func_factory(nominatim.clicmd.special_phrases.SPImporter, 'import_phrases')
+    testdata = SRC_DIR / 'test' / 'testdb'
+    csv_path = str((testdata / 'full_en_phrases_test.csv').resolve())
+
+    if no_replace:
+        call_nominatim('special-phrases', '--import-from-csv', csv_path, '--no-replace')
+    else:
+        call_nominatim('special-phrases', '--import-from-csv', csv_path)
 
     assert func.called == 1
 
@@ -278,6 +295,7 @@ def test_refresh_command(mock_func_factory, temp_db, command, func, tokenizer_mo
 
 def test_refresh_postcodes(mock_func_factory, temp_db, tokenizer_mock):
     func_mock = mock_func_factory(nominatim.tools.postcodes, 'update_postcodes')
+    idx_mock = mock_func_factory(nominatim.indexer.indexer.Indexer, 'index_postcodes')
 
     assert 0 == call_nominatim('refresh', '--postcodes')
     assert func_mock.called == 1