Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refactor SQLConnector connection handling #1394

Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
13 changes: 12 additions & 1 deletion tests/core/test_connector_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestConnectorSQL:

@pytest.fixture()
def connector(self):
return SQLConnector()
return SQLConnector(config={"sqlalchemy_url": "sqlite:///tmp.db"})
qbatten marked this conversation as resolved.
Show resolved Hide resolved

@pytest.mark.parametrize(
"method_name,kwargs,context,unrendered_statement,rendered_statement",
Expand Down Expand Up @@ -130,3 +130,14 @@ def test_update_collation_non_text_type(self):
assert not hasattr(compatible_type, "collation")
# Check that we get the same type we put in
assert str(compatible_type) == "INTEGER"

def test_create_engine_returns_new_engine(self, connector):
engine1 = connector.create_engine()
engine2 = connector.create_engine()
assert engine1 is not engine2

def test_engine_creates_and_returns_cached_engine(self, connector):
assert not connector._cached_engine
engine1 = connector._engine
engine2 = connector._cached_engine
assert engine1 is engine2
qbatten marked this conversation as resolved.
Show resolved Hide resolved