Skip to content

Commit

Permalink
test: Fix integration tests before release (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansergeevitch authored Sep 13, 2023
1 parent 24b71b4 commit 206acee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 56 deletions.
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
from tests.integration.dbapi.utils import assert_deep_eq
Expand Down Expand Up @@ -186,17 +180,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 @@ -239,17 +228,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
2 changes: 1 addition & 1 deletion 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
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
from tests.integration.dbapi.utils import assert_deep_eq

VALS_TO_INSERT = ",".join([f"({i},'{val}')" for (i, val) in enumerate(range(1, 360))])
Expand Down Expand Up @@ -192,17 +185,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 @@ -242,17 +230,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

0 comments on commit 206acee

Please sign in to comment.