5 from nominatim_db.tools.special_phrases.sp_importer import SPImporter
7 # Testing Database Class Pair Retrival using Mock Database
8 def test_get_classtype_pairs(monkeypatch):
10 def load_sub_configuration(self, path, section=None):
11 return {"blackList": {}, "whiteList": {}}
14 def execute(self, query): pass
17 ("highway", "motorway"),
18 ("historic", "castle")
20 def __enter__(self): return self
21 def __exit__(self, exc_type, exc_val, exc_tb): pass
24 def cursor(self): return Cursor()
28 importer = SPImporter(config=config, conn=conn, sp_loader=None)
30 result = importer.get_classtype_pairs()
33 ("highway", "motorway"),
34 ("historic", "castle")
37 assert result == expected
39 # Testing Database Class Pair Retrival using Conftest.py and placex
40 def test_get_classtype_pair_data(placex_table, temp_db_conn):
42 def load_sub_configuration(self, *_):
43 return {'blackList': {}, 'whiteList': {}}
46 placex_table.add(cls='highway', typ='motorway') # edge case 101
49 placex_table.add(cls='amenity', typ='prison') # edge case 99
52 placex_table.add(cls='tourism', typ='hotel')
55 importer = SPImporter(config=config, conn=temp_db_conn, sp_loader=None)
57 result = importer.get_classtype_pairs()
60 ("highway", "motorway"),
64 assert result == expected, f"Expected {expected}, got {result}"
66 def test_get_classtype_pair_data_more(placex_table, temp_db_conn):
68 def load_sub_configuration(self, *_):
69 return {'blackList': {}, 'whiteList': {}}
72 placex_table.add(cls='emergency', typ='firehydrant') # edge case 100, not included
75 placex_table.add(cls='amenity', typ='prison')
78 placex_table.add(cls='tourism', typ='hotel')
81 importer = SPImporter(config=config, conn=temp_db_conn, sp_loader=None)
83 result = importer.get_classtype_pairs()
86 ("amenity", "prison"),
90 assert result == expected, f"Expected {expected}, got {result}"