Skip to content

Commit 980bbc5

Browse files
committed
Add test for cursor description
1 parent c4371fc commit 980bbc5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/client/test_cursor.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ def test_cursor_fetch(mocked_connection):
5757
["bar", "10.10.10.2"],
5858
]
5959

60+
def test_cursor_description(mocked_connection):
61+
cursor = mocked_connection.cursor()
62+
response = {
63+
"col_types": [4, 5],
64+
"cols": ["name", "address"],
65+
"rows": [["foo", "10.10.10.1"], ["bar", "10.10.10.2"]],
66+
"rowcount": 2,
67+
"duration": 123,
68+
}
69+
with mock.patch.object(
70+
mocked_connection.client, "sql", return_value=response
71+
):
72+
cursor.execute("")
73+
assert len(cursor.description) == len(response["cols"])
74+
assert len(cursor.description[0]) == 7 # It's 7 by convention.
75+
for expected_name, name in zip(response["cols"], cursor.description):
76+
assert expected_name == name[0]
77+
78+
cursor.close()
79+
80+
assert cursor.description is None
6081

6182
def test_cursor_executemany(mocked_connection):
6283
"""

0 commit comments

Comments
 (0)