-
-@pytest.fixture
-def sp_wiki_loader(monkeypatch, def_config):
- """
- Return an instance of SPWikiLoader.
- """
- loader = SPWikiLoader(def_config, ['en'])
- monkeypatch.setattr('nominatim.tools.special_phrases.sp_wiki_loader.SPWikiLoader._get_wiki_content',
- mock_get_wiki_content)
- return loader
-
-def mock_get_wiki_content(self, lang):
- """
- Mock the _get_wiki_content() method to return
- static xml test file content.
- """
- return get_test_xml_wiki_content()
-
-def get_test_xml_wiki_content():
- """
- return the content of the static xml test file.
- """
- xml_test_content_path = (TEST_BASE_DIR / 'testdata' / 'special_phrases_test_content.txt').resolve()
- with open(xml_test_content_path) as xml_content_reader:
- return xml_content_reader.read()