2 Test for the command line interface wrapper admin subcommand.
4 These tests just check that the various command line parameters route to the
5 correct functionionality. They use a lot of monkeypatching to avoid executing
10 import nominatim.tools.admin
11 import nominatim.tools.check_database
12 import nominatim.tools.migration
13 import nominatim.clicmd.admin
16 @pytest.mark.parametrize("params", [('--warm', ),
17 ('--warm', '--reverse-only'),
18 ('--warm', '--search-only')])
19 def test_admin_command_legacy(cli_call, mock_func_factory, params):
20 mock_run_legacy = mock_func_factory(nominatim.clicmd.admin, 'run_legacy_script')
22 assert cli_call('admin', *params) == 0
24 assert mock_run_legacy.called == 1
27 def test_admin_command_check_database(cli_call, mock_func_factory):
28 mock = mock_func_factory(nominatim.tools.check_database, 'check_database')
30 assert cli_call('admin', '--check-database') == 0
31 assert mock.called == 1
34 def test_admin_migrate(cli_call, mock_func_factory):
35 mock = mock_func_factory(nominatim.tools.migration, 'migrate')
37 assert cli_call('admin', '--migrate') == 0
38 assert mock.called == 1
41 class TestCliAdminWithDb:
43 @pytest.fixture(autouse=True)
44 def setup_cli_call(self, cli_call, temp_db, cli_tokenizer_mock):
45 self.call_nominatim = cli_call
46 self.tokenizer_mock = cli_tokenizer_mock
49 @pytest.mark.parametrize("func, params", [('analyse_indexing', ('--analyse-indexing', ))])
50 def test_analyse_indexing(self, mock_func_factory, func, params):
51 mock = mock_func_factory(nominatim.tools.admin, func)
53 assert self.call_nominatim('admin', *params) == 0
54 assert mock.called == 1