]> git.openstreetmap.org Git - nominatim.git/blob - test/python/tokenizer/sanitizers/test_tag_japanese.py
946f137ce768a4371a65d5deba52b758d0609ee1
[nominatim.git] / test / python / tokenizer / sanitizers / test_tag_japanese.py
1 from nominatim.data.place_info import PlaceInfo
2 from nominatim.data.place_name import PlaceName
3 from nominatim.tokenizer.place_sanitizer import PlaceSanitizer
4 from typing import Mapping, Optional, List
5 import pytest
6
7 class TestTagJapanese:
8     @pytest.fixture(autouse=True)
9     def setup_country(self, def_config):
10         self.config = def_config
11
12     def run_sanitizer_on(self,type, **kwargs):
13         place = PlaceInfo({
14             'address': kwargs,
15             'country_code': 'jp'
16         })
17         sanitizer_args = {'step': 'tag-japanese'}
18         _, address = PlaceSanitizer([sanitizer_args], self.config).process_names(place)
19         tmp_list = [(p.name,p.kind) for p in address]
20         return sorted(tmp_list)
21
22     def test_on_address(self):
23         res = self.run_sanitizer_on('address', name='foo', ref='bar', ref_abc='baz')
24         assert res == [('bar','ref'),('baz','ref_abc'),('foo','name')]
25
26     def test_housenumber(self):
27         res = self.run_sanitizer_on('address', housenumber='2')
28         assert res == [('2','housenumber')]
29
30     def test_blocknumber(self):
31         res = self.run_sanitizer_on('address', block_number='6')
32         assert res == [('6','housenumber')]
33
34     def test_neighbourhood(self):
35         res = self.run_sanitizer_on('address', neighbourhood='8')
36         assert res == [('8','place')]
37
38     def test_quarter(self):
39         res = self.run_sanitizer_on('address', quarter='kase')
40         assert res==[('kase','place')]
41
42     def test_housenumber_blocknumber(self):
43         res = self.run_sanitizer_on('address', housenumber='2', block_number='6')
44         assert res == [('6-2','housenumber')]
45
46     def test_quarter_neighbourhood(self):
47         res = self.run_sanitizer_on('address', quarter='kase', neighbourhood='8')
48         assert res == [('kase8','place')]
49
50     def test_blocknumber_housenumber_quarter(self):
51         res = self.run_sanitizer_on('address', block_number='6', housenumber='2', quarter='kase')
52         assert res == [('6-2','housenumber'),('kase','place')]
53
54     def test_blocknumber_housenumber_quarter_neighbourhood(self):
55         res = self.run_sanitizer_on('address', block_number='6', housenumber='2', neighbourhood='8')
56         assert res == [('6-2','housenumber'),('8','place')]
57
58     def test_blocknumber_quarter_neighbourhood(self):
59         res = self.run_sanitizer_on('address',block_number='6', quarter='kase', neighbourhood='8')
60         assert res == [('6','housenumber'),('kase8','place')]
61
62     def test_blocknumber_quarter(self):
63         res = self.run_sanitizer_on('address',block_number='6', quarter='kase')
64         assert res == [('6','housenumber'),('kase','place')]
65
66     def test_blocknumber_neighbourhood(self):
67         res = self.run_sanitizer_on('address',block_number='6', neighbourhood='8')
68         assert res == [('6','housenumber'),('8','place')]
69
70     def test_housenumber_quarter_neighbourhood(self):
71         res = self.run_sanitizer_on('address',housenumber='2', quarter='kase', neighbourhood='8')
72         assert res == [('2','housenumber'),('kase8','place')]
73
74     def test_housenumber_quarter(self):
75         res = self.run_sanitizer_on('address',housenumber='2', quarter='kase')
76         assert res == [('2','housenumber'),('kase','place')]
77
78     def test_housenumber_blocknumber_neighbourhood_quarter(self):
79         res = self.run_sanitizer_on('address', block_number='6', housenumber='2', quarter='kase', neighbourhood='8')
80         assert res == [('6-2','housenumber'),('kase8','place')]