2 Tests for specialised conenction and cursor classes.
6 from nominatim.db.connection import connect
10 conn = connect('dbname=' + temp_db)
15 def test_connection_table_exists(db, temp_db_cursor):
16 assert db.table_exists('foobar') == False
18 temp_db_cursor.execute('CREATE TABLE foobar (id INT)')
20 assert db.table_exists('foobar') == True
23 def test_cursor_scalar(db, temp_db_cursor):
24 temp_db_cursor.execute('CREATE TABLE dummy (id INT)')
26 with db.cursor() as cur:
27 assert cur.scalar('SELECT count(*) FROM dummy') == 0
29 def test_cursor_scalar_many_rows(db):
30 with db.cursor() as cur:
31 with pytest.raises(RuntimeError):
32 cur.scalar('SELECT * FROM pg_tables')