1010from firebolt .async_db .cursor import ColType , CursorState
1111from firebolt .common .exception import (
1212 CursorClosedError ,
13+ DataError ,
1314 EngineNotRunningError ,
1415 FireboltDatabaseError ,
1516 OperationalError ,
@@ -175,7 +176,6 @@ async def test_cursor_execute(
175176 assert await query () == - 1 , "Invalid row count for insert query"
176177 assert cursor .rowcount == - 1 , "Invalid rowcount value for insert query"
177178 assert cursor .description is None , "Invalid description for insert query"
178- assert await cursor .fetchone () is None , "Non-empty fetchone for insert query"
179179
180180
181181@mark .asyncio
@@ -264,6 +264,7 @@ async def test_cursor_fetchone(
264264 auth_callback : Callable ,
265265 auth_url : str ,
266266 query_callback : Callable ,
267+ insert_query_callback : Callable ,
267268 query_url : str ,
268269 cursor : Cursor ,
269270):
@@ -284,13 +285,19 @@ async def test_cursor_fetchone(
284285 await cursor .fetchone () is None
285286 ), "fetchone should return None when no rows left to fetch"
286287
288+ httpx_mock .add_callback (insert_query_callback , url = query_url )
289+ await cursor .execute ("sql" )
290+ with raises (DataError ):
291+ await cursor .fetchone ()
292+
287293
288294@mark .asyncio
289295async def test_cursor_fetchmany (
290296 httpx_mock : HTTPXMock ,
291297 auth_callback : Callable ,
292298 auth_url : str ,
293299 query_callback : Callable ,
300+ insert_query_callback : Callable ,
294301 query_url : str ,
295302 cursor : Cursor ,
296303):
@@ -342,13 +349,19 @@ async def test_cursor_fetchmany(
342349 len (await cursor .fetchmany ()) == 0
343350 ), "fetchmany should return empty result set when no rows left to fetch"
344351
352+ httpx_mock .add_callback (insert_query_callback , url = query_url )
353+ await cursor .execute ("sql" )
354+ with raises (DataError ):
355+ await cursor .fetchmany ()
356+
345357
346358@mark .asyncio
347359async def test_cursor_fetchall (
348360 httpx_mock : HTTPXMock ,
349361 auth_callback : Callable ,
350362 auth_url : str ,
351363 query_callback : Callable ,
364+ insert_query_callback : Callable ,
352365 query_url : str ,
353366 cursor : Cursor ,
354367):
@@ -371,6 +384,11 @@ async def test_cursor_fetchall(
371384 len (await cursor .fetchall ()) == 0
372385 ), "fetchmany should return empty result set when no rows left to fetch"
373386
387+ httpx_mock .add_callback (insert_query_callback , url = query_url )
388+ await cursor .execute ("sql" )
389+ with raises (DataError ):
390+ await cursor .fetchall ()
391+
374392
375393# This tests a temporary functionality, needs to be removed when the
376394# functionality is removed
0 commit comments