1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2023 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.version import NOMINATIM_VERSION, NominatimVersion
15 import nominatim.api as napi
17 def test_status_no_extra_info(apiobj, frontend):
18 api = frontend(apiobj)
21 assert result.status == 0
22 assert result.message == 'OK'
23 assert result.software_version == NOMINATIM_VERSION
24 assert result.database_version is None
25 assert result.data_updated is None
28 def test_status_full(apiobj, frontend):
29 import_date = dt.datetime(2022, 12, 7, 14, 14, 46, 0, tzinfo=dt.timezone.utc)
30 apiobj.add_data('import_status',
31 [{'lastimportdate': import_date}])
32 apiobj.add_data('properties',
33 [{'property': 'database_version', 'value': '99.5.4-2'}])
35 api = frontend(apiobj)
38 assert result.status == 0
39 assert result.message == 'OK'
40 assert result.software_version == NOMINATIM_VERSION
41 assert result.database_version == NominatimVersion(99, 5, 4, 2)
42 assert result.data_updated == import_date
45 def test_status_database_not_found(monkeypatch):
46 monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg')
48 api = napi.NominatimAPI(Path('/invalid'), {})
52 assert result.status == 700
53 assert result.message == 'Database connection failed'
54 assert result.software_version == NOMINATIM_VERSION
55 assert result.database_version is None
56 assert result.data_updated is None