- return len(phrases) > 1 \
- and any(p.p_label == 'Embassies' and p.p_class == 'amenity' and p.p_type == 'embassy'
- and p.p_operator == '-' for p in phrases) \
- and any(p.p_label == 'Zip Line' and p.p_class == 'aerialway' and p.p_type == 'zip_line'
- and p.p_operator == '-' for p in phrases)
-
-@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()
+ assert set((p.p_label, p.p_class, p.p_type, p.p_operator) for p in phrases) ==\
+ {('Zip Line', 'aerialway', 'zip_line', '-'),
+ ('Zip Lines', 'aerialway', 'zip_line', '-'),
+ ('Zip Line in', 'aerialway', 'zip_line', 'in'),
+ ('Zip Lines in', 'aerialway', 'zip_line', 'in'),
+ ('Zip Line near', 'aerialway', 'zip_line', 'near'),
+ ('Animal shelter', 'amenity', 'animal_shelter', '-'),
+ ('Animal shelters', 'amenity', 'animal_shelter', '-'),
+ ('Animal shelter in', 'amenity', 'animal_shelter', 'in'),
+ ('Animal shelters in', 'amenity', 'animal_shelter', 'in'),
+ ('Animal shelter near', 'amenity', 'animal_shelter', 'near'),
+ ('Animal shelters near', 'amenity', 'animal_shelter', 'near'),
+ ('Drinking Water near', 'amenity', 'drinking_water', 'near'),
+ ('Water', 'amenity', 'drinking_water', '-'),
+ ('Water in', 'amenity', 'drinking_water', 'in'),
+ ('Water near', 'amenity', 'drinking_water', 'near'),
+ ('Embassy', 'amenity', 'embassy', '-'),
+ ('Embassys', 'amenity', 'embassy', '-'),
+ ('Embassies', 'amenity', 'embassy', '-')}