2 Tests for property table manpulation.
6 from nominatim.db import properties
9 def property_factory(property_table, temp_db_cursor):
10 """ A function fixture that adds a property into the property table.
12 def _add_property(name, value):
13 temp_db_cursor.execute("INSERT INTO nominatim_properties VALUES(%s, %s)",
19 def test_get_property_existing(property_factory, temp_db_conn):
20 property_factory('foo', 'bar')
22 assert properties.get_property(temp_db_conn, 'foo') == 'bar'
25 def test_get_property_unknown(property_factory, temp_db_conn):
26 property_factory('other', 'bar')
28 assert properties.get_property(temp_db_conn, 'foo') is None
31 @pytest.mark.parametrize("prefill", (True, False))
32 def test_set_property_new(property_factory, temp_db_conn, temp_db_cursor, prefill):
34 property_factory('something', 'bar')
36 properties.set_property(temp_db_conn, 'something', 'else')
38 assert temp_db_cursor.scalar("""SELECT value FROM nominatim_properties
39 WHERE property = 'something'""") == 'else'
41 assert properties.get_property(temp_db_conn, 'something') == 'else'