From 7b4c4f1cab339c461a6c897dd86424fc6f6515fa Mon Sep 17 00:00:00 2001 From: ptiurin Date: Thu, 25 May 2023 12:18:12 +0100 Subject: [PATCH 1/3] test: Fix failing tests --- .../test_sqlalchemy_async_integration.py | 15 +-------------- .../integration/test_sqlalchemy_integration.py | 18 ++---------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/tests/integration/test_sqlalchemy_async_integration.py b/tests/integration/test_sqlalchemy_async_integration.py index 298285b..bf55686 100644 --- a/tests/integration/test_sqlalchemy_async_integration.py +++ b/tests/integration/test_sqlalchemy_async_integration.py @@ -3,7 +3,6 @@ import pytest from sqlalchemy import inspect, text from sqlalchemy.engine.base import Connection, Engine -from sqlalchemy.exc import OperationalError class TestAsyncFireboltDialect: @@ -36,18 +35,6 @@ async def test_data_write(self, async_connection: Connection, fact_table_name: s ) assert result.rowcount == 1 assert len(result.fetchall()) == 1 - # Update not supported - with pytest.raises(OperationalError): - await async_connection.execute( - text( - f"UPDATE {fact_table_name} SET dummy='some_other_text' WHERE idx=1" - ) - ) - # Delete works but is not officially supported yet - # with pytest.raises(OperationalError): - # await async_connection.execute( - # text(f"DELETE FROM {fact_table_name} WHERE idx=1") - # ) @pytest.mark.asyncio async def test_set_params(self, async_connection: Engine): @@ -77,7 +64,7 @@ def get_columns(conn: Connection) -> List[Dict]: inspector = inspect(conn) return inspector.get_columns(fact_table_name) - results = await async_connection.run_sync(get_columns) + results = await async_connection.get_columns() assert len(results) > 0 row = results[0] assert isinstance(row, dict) diff --git a/tests/integration/test_sqlalchemy_integration.py b/tests/integration/test_sqlalchemy_integration.py index 2093c45..2a8accc 100644 --- a/tests/integration/test_sqlalchemy_integration.py +++ b/tests/integration/test_sqlalchemy_integration.py @@ -1,10 +1,8 @@ from datetime import date, datetime from decimal import Decimal -import pytest from sqlalchemy import create_engine, text from sqlalchemy.engine.base import Connection, Engine -from sqlalchemy.exc import OperationalError from sqlalchemy.types import ARRAY, INTEGER, TypeEngine @@ -45,23 +43,11 @@ def test_data_write(self, connection: Connection, fact_table_name: str): assert result.fetchall() == [(1, "some_text")] result = connection.execute(text(f"SELECT * FROM {fact_table_name}")) assert len(result.fetchall()) == 1 - # Update not supported - with pytest.raises(OperationalError): - connection.execute( - text( - f"UPDATE {fact_table_name} SET dummy='some_other_text' WHERE idx=1" - ) - ) - # Delete works but is not officially supported yet - # with pytest.raises(OperationalError): - # connection.execute(f"DELETE FROM {fact_table_name} WHERE idx=1") def test_firebolt_types(self, connection: Connection): - result = connection.execute(text("SELECT '1896-01-01' :: DATE_EXT")) + result = connection.execute(text("SELECT '1896-01-01' :: DATE")) assert result.fetchall() == [(date(1896, 1, 1),)] - result = connection.execute( - text("SELECT '1896-01-01 00:01:00' :: TIMESTAMP_EXT") - ) + result = connection.execute(text("SELECT '1896-01-01 00:01:00' :: TIMESTAMP")) assert result.fetchall() == [(datetime(1896, 1, 1, 0, 1, 0, 0),)] result = connection.execute(text("SELECT 100.76 :: DECIMAL(5, 2)")) assert result.fetchall() == [(Decimal("100.76"),)] From e32c96d8a980e82e3a8b04991c121fd3276767a8 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Thu, 25 May 2023 14:30:13 +0100 Subject: [PATCH 2/3] fix --- tests/integration/test_sqlalchemy_async_integration.py | 2 +- tests/integration/test_sqlalchemy_integration.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_sqlalchemy_async_integration.py b/tests/integration/test_sqlalchemy_async_integration.py index bf55686..bb5a051 100644 --- a/tests/integration/test_sqlalchemy_async_integration.py +++ b/tests/integration/test_sqlalchemy_async_integration.py @@ -64,7 +64,7 @@ def get_columns(conn: Connection) -> List[Dict]: inspector = inspect(conn) return inspector.get_columns(fact_table_name) - results = await async_connection.get_columns() + results = await async_connection.run_sync(get_columns) assert len(results) > 0 row = results[0] assert isinstance(row, dict) diff --git a/tests/integration/test_sqlalchemy_integration.py b/tests/integration/test_sqlalchemy_integration.py index 2a8accc..0b1e7a5 100644 --- a/tests/integration/test_sqlalchemy_integration.py +++ b/tests/integration/test_sqlalchemy_integration.py @@ -45,7 +45,7 @@ def test_data_write(self, connection: Connection, fact_table_name: str): assert len(result.fetchall()) == 1 def test_firebolt_types(self, connection: Connection): - result = connection.execute(text("SELECT '1896-01-01' :: DATE")) + result = connection.execute(text("SELECT '1896-01-01' :: PGDATE")) assert result.fetchall() == [(date(1896, 1, 1),)] result = connection.execute(text("SELECT '1896-01-01 00:01:00' :: TIMESTAMP")) assert result.fetchall() == [(datetime(1896, 1, 1, 0, 1, 0, 0),)] From 0fd02fa248576394dc6b3858d24e54459c411256 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Thu, 25 May 2023 15:26:38 +0100 Subject: [PATCH 3/3] fix --- tests/integration/test_sqlalchemy_integration.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_sqlalchemy_integration.py b/tests/integration/test_sqlalchemy_integration.py index 0b1e7a5..202b8da 100644 --- a/tests/integration/test_sqlalchemy_integration.py +++ b/tests/integration/test_sqlalchemy_integration.py @@ -47,7 +47,9 @@ def test_data_write(self, connection: Connection, fact_table_name: str): def test_firebolt_types(self, connection: Connection): result = connection.execute(text("SELECT '1896-01-01' :: PGDATE")) assert result.fetchall() == [(date(1896, 1, 1),)] - result = connection.execute(text("SELECT '1896-01-01 00:01:00' :: TIMESTAMP")) + result = connection.execute( + text("SELECT '1896-01-01 00:01:00' :: TIMESTAMPNTZ") + ) assert result.fetchall() == [(datetime(1896, 1, 1, 0, 1, 0, 0),)] result = connection.execute(text("SELECT 100.76 :: DECIMAL(5, 2)")) assert result.fetchall() == [(Decimal("100.76"),)]