1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2022 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 version_str
15 from nominatim.api import NominatimAPI
17 def test_status_no_extra_info(apiobj, table_factory):
18 table_factory('import_status',
19 definition="lastimportdate timestamp with time zone NOT NULL")
20 table_factory('nominatim_properties',
21 definition='property TEXT, value TEXT')
23 result = apiobj.status()
25 assert result.status == 0
26 assert result.message == 'OK'
27 assert result.software_version == version_str()
28 assert result.database_version is None
29 assert result.data_updated is None
32 def test_status_full(apiobj, table_factory):
33 table_factory('import_status',
34 definition="lastimportdate timestamp with time zone NOT NULL",
35 content=(('2022-12-07 15:14:46+01',),))
36 table_factory('nominatim_properties',
37 definition='property TEXT, value TEXT',
38 content=(('database_version', '99.5.4-2'), ))
40 result = apiobj.status()
42 assert result.status == 0
43 assert result.message == 'OK'
44 assert result.software_version == version_str()
45 assert result.database_version == '99.5.4-2'
46 assert result.data_updated == dt.datetime(2022, 12, 7, 14, 14, 46, 0, tzinfo=dt.timezone.utc)
49 def test_status_database_not_found(monkeypatch):
50 monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg')
52 api = NominatimAPI(Path('/invalid'), {})
56 assert result.status == 700
57 assert result.message == 'Database connection failed'
58 assert result.software_version == version_str()
59 assert result.database_version is None
60 assert result.data_updated is None