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.
13 from nominatim_db.version import NominatimVersion
14 from nominatim_api.version import NOMINATIM_API_VERSION
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_API_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_API_VERSION
41 assert result.database_version == '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(environ={})
52 assert result.status == 700
53 assert result.message == 'Database connection failed'
54 assert result.software_version == NOMINATIM_API_VERSION
55 assert result.database_version is None
56 assert result.data_updated is None