1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Tests for the status API call.
10 from pathlib import Path
14 from nominatim_db.version import NominatimVersion
15 from nominatim_api.version import NOMINATIM_API_VERSION
16 import nominatim_api as napi
18 def test_status_no_extra_info(apiobj, frontend):
19 api = frontend(apiobj)
22 assert result.status == 0
23 assert result.message == 'OK'
24 assert result.software_version == NOMINATIM_API_VERSION
25 assert result.database_version is None
26 assert result.data_updated is None
29 def test_status_full(apiobj, frontend):
30 import_date = dt.datetime(2022, 12, 7, 14, 14, 46, 0, tzinfo=dt.timezone.utc)
31 apiobj.add_data('import_status',
32 [{'lastimportdate': import_date}])
33 apiobj.add_data('properties',
34 [{'property': 'database_version', 'value': '99.5.4-2'}])
36 api = frontend(apiobj)
39 assert result.status == 0
40 assert result.message == 'OK'
41 assert result.software_version == NOMINATIM_API_VERSION
42 assert result.database_version == '99.5.4-2'
43 assert result.data_updated == import_date
46 def test_status_database_not_found(monkeypatch):
47 monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg')
49 api = napi.NominatimAPI(Path('/invalid'), {})
53 assert result.status == 700
54 assert result.message == 'Database connection failed'
55 assert result.software_version == NOMINATIM_API_VERSION
56 assert result.database_version is None
57 assert result.data_updated is None