X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/9d31a6711605cd4ebea09ca1675e2549b706ba5b..b0067a0345c2ab7793614925d6150141ef5f18f0:/test/python/api/test_api_status.py diff --git a/test/python/api/test_api_status.py b/test/python/api/test_api_status.py index aae5055e..2acde2ec 100644 --- a/test/python/api/test_api_status.py +++ b/test/python/api/test_api_status.py @@ -2,7 +2,7 @@ # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2022 by the Nominatim developer community. +# Copyright (C) 2023 by the Nominatim developer community. # For a full list of authors see the git log. """ Tests for the status API call. @@ -11,50 +11,46 @@ from pathlib import Path import datetime as dt import pytest -from nominatim.version import version_str -from nominatim.api import NominatimAPI +from nominatim.version import NOMINATIM_VERSION, NominatimVersion +import nominatim.api as napi -def test_status_no_extra_info(apiobj, table_factory): - table_factory('import_status', - definition="lastimportdate timestamp with time zone NOT NULL") - table_factory('nominatim_properties', - definition='property TEXT, value TEXT') - - result = apiobj.status() +def test_status_no_extra_info(apiobj, frontend): + api = frontend(apiobj) + result = api.status() assert result.status == 0 assert result.message == 'OK' - assert result.software_version == version_str() + assert result.software_version == NOMINATIM_VERSION assert result.database_version is None assert result.data_updated is None -def test_status_full(apiobj, table_factory): - table_factory('import_status', - definition="lastimportdate timestamp with time zone NOT NULL", - content=(('2022-12-07 15:14:46+01',),)) - table_factory('nominatim_properties', - definition='property TEXT, value TEXT', - content=(('database_version', '99.5.4-2'), )) +def test_status_full(apiobj, frontend): + import_date = dt.datetime(2022, 12, 7, 14, 14, 46, 0, tzinfo=dt.timezone.utc) + apiobj.add_data('import_status', + [{'lastimportdate': import_date}]) + apiobj.add_data('properties', + [{'property': 'database_version', 'value': '99.5.4-2'}]) - result = apiobj.status() + api = frontend(apiobj) + result = api.status() assert result.status == 0 assert result.message == 'OK' - assert result.software_version == version_str() - assert result.database_version == '99.5.4-2' - assert result.data_updated == dt.datetime(2022, 12, 7, 14, 14, 46, 0, tzinfo=dt.timezone.utc) + assert result.software_version == NOMINATIM_VERSION + assert result.database_version == NominatimVersion(99, 5, 4, 2) + assert result.data_updated == import_date def test_status_database_not_found(monkeypatch): monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg') - api = NominatimAPI(Path('/invalid'), {}) + api = napi.NominatimAPI(Path('/invalid'), {}) result = api.status() assert result.status == 700 - assert result.message == 'No database' - assert result.software_version == version_str() + assert result.message == 'Database connection failed' + assert result.software_version == NOMINATIM_VERSION assert result.database_version is None assert result.data_updated is None