Skip to content

Commit 3db0775

Browse files
committed
tested
1 parent cfa04be commit 3db0775

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

tests/test_004_cursor.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10292,62 +10292,6 @@ def test_uuid_insert_with_none(cursor, db_connection):
1029210292
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
1029310293
db_connection.commit()
1029410294

10295-
def test_executemany_uuid_insert_and_select(cursor, db_connection):
10296-
"""Test inserting multiple UUIDs using executemany and verifying retrieval."""
10297-
table_name = "#pytest_uuid_executemany"
10298-
10299-
try:
10300-
# Drop and create a temporary table for the test
10301-
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
10302-
cursor.execute(f"""
10303-
CREATE TABLE {table_name} (
10304-
id UNIQUEIDENTIFIER PRIMARY KEY,
10305-
description NVARCHAR(50)
10306-
)
10307-
""")
10308-
db_connection.commit()
10309-
10310-
# Generate data for insertion
10311-
data_to_insert = []
10312-
uuids_to_check = {}
10313-
for i in range(5):
10314-
new_uuid = uuid.uuid4()
10315-
description = f"Item {i}"
10316-
data_to_insert.append((new_uuid, description))
10317-
uuids_to_check[description] = new_uuid
10318-
10319-
# Insert all data with a single call to executemany
10320-
sql = f"INSERT INTO {table_name} (id, description) VALUES (?, ?)"
10321-
cursor.executemany(sql, data_to_insert)
10322-
db_connection.commit()
10323-
10324-
# Verify the number of rows inserted
10325-
assert cursor.rowcount == 5, f"Expected 5 rows inserted, but got {cursor.rowcount}"
10326-
10327-
# Fetch all data from the table
10328-
cursor.execute(f"SELECT id, description FROM {table_name}")
10329-
rows = cursor.fetchall()
10330-
10331-
# Verify the number of fetched rows
10332-
assert len(rows) == len(data_to_insert), "Number of fetched rows does not match."
10333-
10334-
# Verify each fetched row's data and type
10335-
for row in rows:
10336-
retrieved_uuid, retrieved_desc = row
10337-
10338-
# Assert the type is correct
10339-
assert isinstance(retrieved_uuid, uuid.UUID), f"Expected uuid.UUID, got {type(retrieved_uuid)}"
10340-
10341-
# Assert the value matches the original data
10342-
expected_uuid = uuids_to_check.get(retrieved_desc)
10343-
assert expected_uuid is not None, f"Retrieved description '{retrieved_desc}' was not in the original data."
10344-
assert retrieved_uuid == expected_uuid, f"UUID mismatch for '{retrieved_desc}': expected {expected_uuid}, got {retrieved_uuid}"
10345-
10346-
finally:
10347-
# Clean up the temporary table
10348-
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
10349-
db_connection.commit()
10350-
1035110295
def test_close(db_connection):
1035210296
"""Test closing the cursor"""
1035310297
try:

0 commit comments

Comments
 (0)