- with psycopg2.connect('dbname=' + temp_db) as conn:
- db_utils.execute_file(conn, tmpfile)
+ db_utils.execute_file(dsn, tmpfile)
+
+ temp_db_cursor.execute('SELECT * FROM test')
+
+ assert temp_db_cursor.rowcount == 1
+ assert temp_db_cursor.fetchone()[0] == 56
+
+def test_execute_file_bad_file(dsn, tmp_path):
+ with pytest.raises(FileNotFoundError):
+ db_utils.execute_file(dsn, tmp_path / 'test2.sql')