Skip to content

Commit

Permalink
tests: replicate dbapi systest changes from #412 into new module
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Aug 9, 2021
1 parent c7620d5 commit d77365f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tests/system/test_dbapi.py
Expand Up @@ -265,27 +265,28 @@ def test_execute_many(shared_instance, dbapi_database):
conn = Connection(shared_instance, dbapi_database)
cursor = conn.cursor()

cursor.execute(
row_data = [
(1, "first-name", "last-name", "test.email@example.com"),
(2, "first-name2", "last-name2", "test.email2@example.com"),
]
cursor.executemany(
"""
INSERT INTO contacts (contact_id, first_name, last_name, email)
VALUES (1, 'first-name', 'last-name', 'test.email@example.com'),
(2, 'first-name2', 'last-name2', 'test.email2@example.com')
"""
VALUES (%s, %s, %s, %s)
""",
row_data,
)
conn.commit()

cursor.executemany(
"""
SELECT * FROM contacts WHERE contact_id = @a1
""",
({"a1": 1}, {"a1": 2}),
"""SELECT * FROM contacts WHERE contact_id = @a1""", ({"a1": 1}, {"a1": 2}),
)
res = cursor.fetchall()
conn.commit()

assert len(res) == 2
assert res[0][0] == 1
assert res[1][0] == 2
assert len(res) == len(row_data)
for found, expected in zip(res, row_data):
assert found[0] == expected[0]

# checking that execute() and executemany()
# results are not mixed together
Expand Down

0 comments on commit d77365f

Please sign in to comment.