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):
18 result = apiobj.api.status()
20 assert result.status == 0
21 assert result.message == 'OK'
22 assert result.software_version == NOMINATIM_VERSION
23 assert result.database_version is None
24 assert result.data_updated is None
27 def test_status_full(apiobj):
28 import_date = dt.datetime(2022, 12, 7, 14, 14, 46, 0, tzinfo=dt.timezone.utc)
29 apiobj.add_data('import_status',
30 [{'lastimportdate': import_date}])
31 apiobj.add_data('properties',
32 [{'property': 'database_version', 'value': '99.5.4-2'}])
34 result = apiobj.api.status()
36 assert result.status == 0
37 assert result.message == 'OK'
38 assert result.software_version == NOMINATIM_VERSION
39 assert result.database_version == NominatimVersion(99, 5, 4, 2)
40 assert result.data_updated == import_date
43 def test_status_database_not_found(monkeypatch):
44 monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg')
46 api = napi.NominatimAPI(Path('/invalid'), {})
50 assert result.status == 700
51 assert result.message == 'Database connection failed'
52 assert result.software_version == NOMINATIM_VERSION
53 assert result.database_version is None
54 assert result.data_updated is None