#
# This file is part of Nominatim. (https://nominatim.org)
#
-# Copyright (C) 2024 by the Nominatim developer community.
+# Copyright (C) 2025 by the Nominatim developer community.
# For a full list of authors see the git log.
"""
Tests for status table manipulation.
<node id="45673" visible="true" version="1" changeset="2047" timestamp="2006-01-27T22:09:10Z" user="Foo" uid="111" lat="48.7586670" lon="8.1343060">
</node>
</osm>
-"""
+""" # noqa
+
def iso_date(date):
return dt.datetime.strptime(date, nominatim_db.db.status.ISODATE_FORMAT)\
def test_compute_database_date_from_osm2pgsql_nodata(table_factory, temp_db_conn):
table_factory('osm2pgsql_properties', 'property TEXT, value TEXT')
- with pytest.raises(UsageError, match='Cannot determine database date from data in offline mode'):
+ with pytest.raises(UsageError,
+ match='Cannot determine database date from data in offline mode'):
nominatim_db.db.status.compute_database_date(temp_db_conn, offline=True)
place_row(osm_type='N', osm_id=45673)
requested_url = []
+
def mock_url(url):
requested_url.append(url)
return OSM_NODE_DATA
place_row(osm_type='N', osm_id=45673)
requested_url = []
+
def mock_url(url):
requested_url.append(url)
return '<osm version="0.6" generator="OpenStre'
date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
nominatim_db.db.status.set_status(temp_db_conn, date=date)
- assert temp_db_cursor.row_set("SELECT * FROM import_status") == \
- {(date, None, True)}
+ assert temp_db_cursor.row_set("SELECT * FROM import_status") == {(date, None, True)}
def test_set_status_filled_table(temp_db_conn, temp_db_cursor):
date = dt.datetime.fromordinal(1000100).replace(tzinfo=dt.timezone.utc)
nominatim_db.db.status.set_status(temp_db_conn, date=date, seq=456, indexed=False)
- assert temp_db_cursor.row_set("SELECT * FROM import_status") == \
- {(date, 456, False)}
+ assert temp_db_cursor.row_set("SELECT * FROM import_status") == {(date, 456, False)}
def test_set_status_missing_date(temp_db_conn, temp_db_cursor):
nominatim_db.db.status.set_status(temp_db_conn, date=None, seq=456, indexed=False)
- assert temp_db_cursor.row_set("SELECT * FROM import_status") == \
- {(date, 456, False)}
+ assert temp_db_cursor.row_set("SELECT * FROM import_status") == {(date, 456, False)}
def test_get_status_empty_table(temp_db_conn):
date = dt.datetime.fromordinal(1000000).replace(tzinfo=dt.timezone.utc)
nominatim_db.db.status.set_status(temp_db_conn, date=date, seq=667, indexed=False)
- assert nominatim_db.db.status.get_status(temp_db_conn) == \
- (date, 667, False)
+ assert nominatim_db.db.status.get_status(temp_db_conn) == (date, 667, False)
@pytest.mark.parametrize("old_state", [True, False])