Skip to content

Commit 65cc742

Browse files
authored
test: Fix API return values in integration (#316)
1 parent 1b8edaa commit 65cc742

File tree

4 files changed

+25
-58
lines changed

4 files changed

+25
-58
lines changed

tests/integration/dbapi/async/test_queries_async.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55
from pytest import mark, raises
66

7-
from firebolt.async_db import (
8-
Binary,
9-
Connection,
10-
Cursor,
11-
DataError,
12-
OperationalError,
13-
)
7+
from firebolt.async_db import Binary, Connection, Cursor, OperationalError
148
from firebolt.async_db.cursor import QueryStatus
159
from firebolt.common._types import ColType, Column
1610

@@ -260,17 +254,12 @@ async def test_insert(connection: Connection) -> None:
260254
"""Insert and delete queries are handled properly."""
261255

262256
async def test_empty_query(c: Cursor, query: str) -> None:
263-
assert await c.execute(query) == -1, "Invalid row count returned"
264-
assert c.rowcount == -1, "Invalid rowcount value"
257+
assert await c.execute(query) == 0, "Invalid row count returned"
258+
assert c.rowcount == 0, "Invalid rowcount value"
265259
assert c.description is None, "Invalid description"
266-
with raises(DataError):
267-
await c.fetchone()
268-
269-
with raises(DataError):
270-
await c.fetchmany()
271-
272-
with raises(DataError):
273-
await c.fetchall()
260+
assert await c.fetchone() is None
261+
assert len(await c.fetchmany()) == 0
262+
assert len(await c.fetchall()) == 0
274263

275264
with connection.cursor() as c:
276265
await c.execute("DROP TABLE IF EXISTS test_insert_async_tb")
@@ -313,17 +302,12 @@ async def test_parameterized_query(connection: Connection) -> None:
313302
"""Query parameters are handled properly."""
314303

315304
async def test_empty_query(c: Cursor, query: str, params: tuple) -> None:
316-
assert await c.execute(query, params) == -1, "Invalid row count returned"
317-
assert c.rowcount == -1, "Invalid rowcount value"
305+
assert await c.execute(query, params) == 0, "Invalid row count returned"
306+
assert c.rowcount == 0, "Invalid rowcount value"
318307
assert c.description is None, "Invalid description"
319-
with raises(DataError):
320-
await c.fetchone()
321-
322-
with raises(DataError):
323-
await c.fetchmany()
324-
325-
with raises(DataError):
326-
await c.fetchall()
308+
assert await c.fetchone() is None
309+
assert len(await c.fetchmany()) == 0
310+
assert len(await c.fetchall()) == 0
327311

328312
with connection.cursor() as c:
329313
await c.execute("DROP TABLE IF EXISTS test_tb_async_parameterized")

tests/integration/dbapi/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def all_types_query() -> str:
6363
"30000000000 as uint64, "
6464
"-30000000000 as int64, "
6565
"cast(1.23 AS FLOAT) as float32, "
66-
"1.2345678901234 as float64, "
66+
"1.23456789012 as float64, "
6767
"'text' as \"string\", "
6868
"CAST('2021-03-28' AS DATE) as \"date\", "
6969
"pgdate '0001-01-01' as \"pgdate\", "
@@ -118,7 +118,7 @@ def all_types_query_response(timezone_offset_seconds: int) -> List[ColType]:
118118
30000000000,
119119
-30000000000,
120120
1.23,
121-
1.2345678901234,
121+
1.23456789012,
122122
"text",
123123
date(2021, 3, 28),
124124
date(1, 1, 1),

tests/integration/dbapi/sync/test_queries.py

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@
88
from firebolt.async_db.cursor import QueryStatus
99
from firebolt.client.auth import Auth
1010
from firebolt.common._types import ColType, Column
11-
from firebolt.db import (
12-
Binary,
13-
Connection,
14-
Cursor,
15-
DataError,
16-
OperationalError,
17-
connect,
18-
)
11+
from firebolt.db import Binary, Connection, Cursor, OperationalError, connect
1912

2013
VALS_TO_INSERT = ",".join([f"({i},'{val}')" for (i, val) in enumerate(range(1, 360))])
2114
LONG_INSERT = f"INSERT INTO test_tbl VALUES {VALS_TO_INSERT}"
@@ -209,17 +202,12 @@ def test_insert(connection: Connection) -> None:
209202
"""Insert and delete queries are handled properly."""
210203

211204
def test_empty_query(c: Cursor, query: str) -> None:
212-
assert c.execute(query) == -1, "Invalid row count returned"
213-
assert c.rowcount == -1, "Invalid rowcount value"
205+
assert c.execute(query) == 0, "Invalid row count returned"
206+
assert c.rowcount == 0, "Invalid rowcount value"
214207
assert c.description is None, "Invalid description"
215-
with raises(DataError):
216-
c.fetchone()
217-
218-
with raises(DataError):
219-
c.fetchmany()
220-
221-
with raises(DataError):
222-
c.fetchall()
208+
assert c.fetchone() is None
209+
assert len(c.fetchmany()) == 0
210+
assert len(c.fetchall()) == 0
223211

224212
with connection.cursor() as c:
225213
c.execute("DROP TABLE IF EXISTS test_insert_tb")
@@ -259,17 +247,12 @@ def test_parameterized_query(connection: Connection) -> None:
259247
"""Query parameters are handled properly."""
260248

261249
def test_empty_query(c: Cursor, query: str, params: tuple) -> None:
262-
assert c.execute(query, params) == -1, "Invalid row count returned"
263-
assert c.rowcount == -1, "Invalid rowcount value"
250+
assert c.execute(query, params) == 0, "Invalid row count returned"
251+
assert c.rowcount == 0, "Invalid rowcount value"
264252
assert c.description is None, "Invalid description"
265-
with raises(DataError):
266-
c.fetchone()
267-
268-
with raises(DataError):
269-
c.fetchmany()
270-
271-
with raises(DataError):
272-
c.fetchall()
253+
assert c.fetchone() is None
254+
assert len(c.fetchmany()) == 0
255+
assert len(c.fetchall()) == 0
273256

274257
with connection.cursor() as c:
275258
c.execute("DROP TABLE IF EXISTS test_tb_parameterized")

tests/integration/dbapi/sync/test_system_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def check_engine_exists(cursor, engine_name, db_name):
114114
@mark.xdist_group(name="system_engine")
115115
def test_alter_engine(setup_dbs, connection_system_engine, engine_name):
116116
with connection_system_engine.cursor() as cursor:
117-
cursor.execute(f"ALTER ENGINE {engine_name} SET SPEC = B2")
117+
cursor.execute(f"ALTER ENGINE {engine_name} SET SPEC = 'B2'")
118118

119119
cursor.execute("SHOW ENGINES")
120120
engines = cursor.fetchall()

0 commit comments

Comments
 (0)