+from nominatim.tools.special_phrases.sp_importer import SPImporter
+from nominatim.tools.special_phrases.sp_wiki_loader import SPWikiLoader
+from nominatim.tools.special_phrases.special_phrase import SpecialPhrase
+from nominatim.errors import UsageError
+
+from cursor import CursorForTesting
+
+@pytest.fixture
+def testfile_dir(src_dir):
+ return src_dir / 'test' / 'testfiles'
+
+
+@pytest.fixture
+def sp_importer(temp_db_conn, def_config, temp_phplib_dir_with_migration):
+ """
+ Return an instance of SPImporter.
+ """
+ loader = SPWikiLoader(def_config, ['en'])
+ return SPImporter(def_config, temp_phplib_dir_with_migration, temp_db_conn, loader)
+
+
+@pytest.fixture
+def temp_phplib_dir_with_migration(src_dir, tmp_path):
+ """
+ Return temporary phpdir with migration subdirectory and
+ PhraseSettingsToJson.php script inside.
+ """
+ migration_file = (src_dir / 'lib-php' / 'migration' / 'PhraseSettingsToJson.php').resolve()
+
+ phpdir = tmp_path / 'tempphp'
+ phpdir.mkdir()
+
+ (phpdir / 'migration').mkdir()
+ migration_dest_path = (phpdir / 'migration' / 'PhraseSettingsToJson.php').resolve()
+ copyfile(str(migration_file), str(migration_dest_path))
+
+ return phpdir
+
+
+@pytest.fixture
+def xml_wiki_content(src_dir):
+ """
+ return the content of the static xml test file.
+ """
+ xml_test_content = src_dir / 'test' / 'testdata' / 'special_phrases_test_content.txt'
+ return xml_test_content.read_text()