test: use table_rows() and execute_values() where possible

Some uses of scalar() could also be replaced with convenience
functions from the word table mock.
This commit is contained in:
Sarah Hoffmann
2021-05-19 10:51:10 +02:00
parent 510eb53f53
commit 65bd749918
7 changed files with 23 additions and 26 deletions

View File

@@ -4,7 +4,6 @@ import tempfile
from pathlib import Path
import psycopg2
import psycopg2.extras
import pytest
SRC_DIR = Path(__file__) / '..' / '..' / '..'
@@ -91,8 +90,7 @@ def table_factory(temp_db_cursor):
def mk_table(name, definition='id INT', content=None):
temp_db_cursor.execute('CREATE TABLE {} ({})'.format(name, definition))
if content is not None:
psycopg2.extras.execute_values(
temp_db_cursor, "INSERT INTO {} VALUES %s".format(name), content)
temp_db_cursor.execute_values("INSERT INTO {} VALUES %s".format(name), content)
return mk_table