+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
"""
Tests for methods of the SPWikiLoader class.
"""
"""
Return an instance of SPWikiLoader.
"""
- loader = SPWikiLoader(def_config, ['en'])
- monkeypatch.setattr('nominatim.tools.special_phrases.sp_wiki_loader.SPWikiLoader._get_wiki_content',
- lambda self, lang: xml_wiki_content)
+ monkeypatch.setenv('NOMINATIM_LANGUAGES', 'en')
+ loader = SPWikiLoader(def_config)
+ monkeypatch.setattr('nominatim.tools.special_phrases.sp_wiki_loader._get_wiki_content',
+ lambda lang: xml_wiki_content)
return loader
-def test_parse_xml(sp_wiki_loader, xml_wiki_content):
- """
- Test method parse_xml()
- Should return the right SpecialPhrase objects.
- """
- phrases = sp_wiki_loader.parse_xml(xml_wiki_content)
- check_phrases_content(phrases)
-
-
-def test_next(sp_wiki_loader):
+def test_generate_phrases(sp_wiki_loader):
"""
Test objects returned from the next() method.
It should return all SpecialPhrases objects of
the 'en' special phrases.
"""
- phrases = next(sp_wiki_loader)
+ phrases = list(sp_wiki_loader.generate_phrases())
check_phrases_content(phrases)
def check_phrases_content(phrases):