Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 11 additions & 27 deletions tests/integration/dbapi/async/test_queries_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

from pytest import mark, raises

from firebolt.async_db import (
Binary,
Connection,
Cursor,
DataError,
OperationalError,
)
from firebolt.async_db import Binary, Connection, Cursor, OperationalError
from firebolt.async_db.cursor import QueryStatus
from firebolt.common._types import ColType, Column

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

async def test_empty_query(c: Cursor, query: str) -> None:
assert await c.execute(query) == -1, "Invalid row count returned"
assert c.rowcount == -1, "Invalid rowcount value"
assert await c.execute(query) == 0, "Invalid row count returned"
assert c.rowcount == 0, "Invalid rowcount value"
assert c.description is None, "Invalid description"
with raises(DataError):
await c.fetchone()

with raises(DataError):
await c.fetchmany()

with raises(DataError):
await c.fetchall()
assert await c.fetchone() is None
assert len(await c.fetchmany()) == 0
assert len(await c.fetchall()) == 0

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

async def test_empty_query(c: Cursor, query: str, params: tuple) -> None:
assert await c.execute(query, params) == -1, "Invalid row count returned"
assert c.rowcount == -1, "Invalid rowcount value"
assert await c.execute(query, params) == 0, "Invalid row count returned"
assert c.rowcount == 0, "Invalid rowcount value"
assert c.description is None, "Invalid description"
with raises(DataError):
await c.fetchone()

with raises(DataError):
await c.fetchmany()

with raises(DataError):
await c.fetchall()
assert await c.fetchone() is None
assert len(await c.fetchmany()) == 0
assert len(await c.fetchall()) == 0

with connection.cursor() as c:
await c.execute("DROP TABLE IF EXISTS test_tb_async_parameterized")
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/dbapi/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def all_types_query() -> str:
"30000000000 as uint64, "
"-30000000000 as int64, "
"cast(1.23 AS FLOAT) as float32, "
"1.2345678901234 as float64, "
"1.23456789012 as float64, "
"'text' as \"string\", "
"CAST('2021-03-28' AS DATE) as \"date\", "
"pgdate '0001-01-01' as \"pgdate\", "
Expand Down Expand Up @@ -118,7 +118,7 @@ def all_types_query_response(timezone_offset_seconds: int) -> List[ColType]:
30000000000,
-30000000000,
1.23,
1.2345678901234,
1.23456789012,
"text",
date(2021, 3, 28),
date(1, 1, 1),
Expand Down
39 changes: 11 additions & 28 deletions tests/integration/dbapi/sync/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
from firebolt.async_db.cursor import QueryStatus
from firebolt.client.auth import Auth
from firebolt.common._types import ColType, Column
from firebolt.db import (
Binary,
Connection,
Cursor,
DataError,
OperationalError,
connect,
)
from firebolt.db import Binary, Connection, Cursor, OperationalError, connect

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

def test_empty_query(c: Cursor, query: str) -> None:
assert c.execute(query) == -1, "Invalid row count returned"
assert c.rowcount == -1, "Invalid rowcount value"
assert c.execute(query) == 0, "Invalid row count returned"
assert c.rowcount == 0, "Invalid rowcount value"
assert c.description is None, "Invalid description"
with raises(DataError):
c.fetchone()

with raises(DataError):
c.fetchmany()

with raises(DataError):
c.fetchall()
assert c.fetchone() is None
assert len(c.fetchmany()) == 0
assert len(c.fetchall()) == 0

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

def test_empty_query(c: Cursor, query: str, params: tuple) -> None:
assert c.execute(query, params) == -1, "Invalid row count returned"
assert c.rowcount == -1, "Invalid rowcount value"
assert c.execute(query, params) == 0, "Invalid row count returned"
assert c.rowcount == 0, "Invalid rowcount value"
assert c.description is None, "Invalid description"
with raises(DataError):
c.fetchone()

with raises(DataError):
c.fetchmany()

with raises(DataError):
c.fetchall()
assert c.fetchone() is None
assert len(c.fetchmany()) == 0
assert len(c.fetchall()) == 0

with connection.cursor() as c:
c.execute("DROP TABLE IF EXISTS test_tb_parameterized")
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/dbapi/sync/test_system_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def check_engine_exists(cursor, engine_name, db_name):
@mark.xdist_group(name="system_engine")
def test_alter_engine(setup_dbs, connection_system_engine, engine_name):
with connection_system_engine.cursor() as cursor:
cursor.execute(f"ALTER ENGINE {engine_name} SET SPEC = B2")
cursor.execute(f"ALTER ENGINE {engine_name} SET SPEC = 'B2'")

cursor.execute("SHOW ENGINES")
engines = cursor.fetchall()
Expand Down