5 class MockParamCapture:
6 """ Mock that records the parameters with which a function was called
7 as well as the number of calls.
9 def __init__(self, retval=0):
11 self.return_value = retval
13 self.last_kwargs = None
15 def __call__(self, *args, **kwargs):
18 self.last_kwargs = kwargs
19 return self.return_value
24 def cli_call(src_dir):
25 """ Call the nominatim main function with the correct paths set.
26 Returns a function that can be called with the desired CLI arguments.
28 def _call_nominatim(*args):
29 return nominatim.cli.nominatim(module_dir='MODULE NOT AVAILABLE',
30 osm2pgsql_path='OSM2PGSQL NOT AVAILABLE',
31 phplib_dir=str(src_dir / 'lib-php'),
32 data_dir=str(src_dir / 'data'),
33 phpcgi_path='/usr/bin/php-cgi',
34 sqllib_dir=str(src_dir / 'lib-sql'),
35 config_dir=str(src_dir / 'settings'),
38 return _call_nominatim
42 def mock_run_legacy(monkeypatch):
43 mock = MockParamCapture()
44 monkeypatch.setattr(nominatim.cli, 'run_legacy_script', mock)
49 def mock_func_factory(monkeypatch):
50 def get_mock(module, func):
51 mock = MockParamCapture()
53 monkeypatch.setattr(module, func, mock)