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
8 @pytest.fixture(autouse=True)
9 def setup_country(self, def_config):
10 self.config = def_config
12 def run_sanitizer_on(self,type, **kwargs):
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)
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')]
26 def test_housenumber(self):
27 res = self.run_sanitizer_on('address', housenumber='2')
28 assert res == [('2','housenumber')]
30 def test_blocknumber(self):
31 res = self.run_sanitizer_on('address', block_number='6')
32 assert res == [('6','housenumber')]
34 def test_neighbourhood(self):
35 res = self.run_sanitizer_on('address', neighbourhood='8')
36 assert res == [('8','place')]
38 def test_quarter(self):
39 res = self.run_sanitizer_on('address', quarter='kase')
40 assert res==[('kase','place')]
42 def test_housenumber_blocknumber(self):
43 res = self.run_sanitizer_on('address', housenumber='2', block_number='6')
44 assert res == [('6-2','housenumber')]
46 def test_quarter_neighbourhood(self):
47 res = self.run_sanitizer_on('address', quarter='kase', neighbourhood='8')
48 assert res == [('kase8','place')]
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')]
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')]
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')]
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')]
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')]
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')]
74 def test_housenumber_quarter(self):
75 res = self.run_sanitizer_on('address',housenumber='2', quarter='kase')
76 assert res == [('2','housenumber'),('kase','place')]
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')]