2 Tests for property table manpulation.
6 from nominatim.db import properties
9 def prop_table(table_factory):
10 table_factory('nominatim_properties', 'property TEXT, value TEXT')
13 def test_get_property_existing(prop_table, temp_db_conn, temp_db_cursor):
14 temp_db_cursor.execute("INSERT INTO nominatim_properties VALUES('foo', 'bar')")
16 assert properties.get_property(temp_db_conn, 'foo') == 'bar'
19 def test_get_property_unknown(prop_table, temp_db_conn, temp_db_cursor):
20 temp_db_cursor.execute("INSERT INTO nominatim_properties VALUES('other', 'bar')")
22 assert properties.get_property(temp_db_conn, 'foo') is None
25 @pytest.mark.parametrize("prefill", (True, False))
26 def test_set_property_new(prop_table, temp_db_conn, temp_db_cursor, prefill):
28 temp_db_cursor.execute("INSERT INTO nominatim_properties VALUES('something', 'bar')")
30 properties.set_property(temp_db_conn, 'something', 'else')
32 assert temp_db_cursor.scalar("""SELECT value FROM nominatim_properties
33 WHERE property = 'something'""") == 'else'
35 assert properties.get_property(temp_db_conn, 'something') == 'else'