Skip to content

Commit

Permalink
test: Use future=True param to create engines
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Dec 6, 2023
1 parent 9df942d commit 948685e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

def setup_test_table(table_name, sqlalchemy_url):
"""setup any state specific to the execution of the given module."""
engine = sqlalchemy.create_engine(sqlalchemy_url)
engine = sqlalchemy.create_engine(sqlalchemy_url, future=True)
fake = Faker()

date1 = datetime.date(2022, 11, 1)
Expand All @@ -49,7 +49,7 @@ def setup_test_table(table_name, sqlalchemy_url):
Column("updated_at", DateTime(), nullable=False),
Column("name", String()),
)
with engine.connect() as conn:
with engine.connect() as conn, conn.begin():
metadata_obj.create_all(conn)
conn.execute(text(f"TRUNCATE TABLE {table_name}"))
for _ in range(1000):
Expand All @@ -60,7 +60,7 @@ def setup_test_table(table_name, sqlalchemy_url):


def teardown_test_table(table_name, sqlalchemy_url):
engine = sqlalchemy.create_engine(sqlalchemy_url)
engine = sqlalchemy.create_engine(sqlalchemy_url, future=True)
with engine.connect() as conn:
conn.execute(text(f"DROP TABLE {table_name}"))

Expand Down Expand Up @@ -137,7 +137,7 @@ def test_temporal_datatypes():
schema checks, and performs similar tests on times and timestamps.
"""
table_name = "test_temporal_datatypes"
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"])
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_temporal_datatypes():
def test_jsonb_json():
"""JSONB and JSON Objects weren't being selected, make sure they are now"""
table_name = "test_jsonb_json"
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"])
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_jsonb_json():
def test_decimal():
"""Schema was wrong for Decimal objects. Check they are correctly selected."""
table_name = "test_decimal"
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"])
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(
Expand Down Expand Up @@ -294,7 +294,7 @@ def test_decimal():
def test_filter_schemas():
"""Only return tables from a given schema"""
table_name = "test_filter_schemas"
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"])
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(table_name, metadata_obj, Column("id", BIGINT), schema="new_schema")
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_invalid_python_dates():
"""
table_name = "test_invalid_python_dates"
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"])
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(
Expand Down
5 changes: 3 additions & 2 deletions tests/test_replication_key.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests standard tap features using the built-in SDK tests library."""

import copy
import json

Expand Down Expand Up @@ -54,7 +55,7 @@ def test_null_replication_key_with_start_date():
greater than the start date should be synced.
"""
table_name = "test_null_replication_key_with_start_date"
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"])
engine = sqlalchemy.create_engine(SAMPLE_CONFIG["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(
Expand Down Expand Up @@ -111,7 +112,7 @@ def test_null_replication_key_without_start_date():

modified_config = copy.deepcopy(SAMPLE_CONFIG)
modified_config["start_date"] = None
engine = sqlalchemy.create_engine(modified_config["sqlalchemy_url"])
engine = sqlalchemy.create_engine(modified_config["sqlalchemy_url"], future=True)

metadata_obj = MetaData()
table = Table(
Expand Down

0 comments on commit 948685e

Please sign in to comment.