Skip to content

Commit

Permalink
Added a python driver
Browse files Browse the repository at this point in the history
  • Loading branch information
kenstott committed Nov 7, 2024
1 parent ccae79b commit 5c3a350
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Empty file.
27 changes: 27 additions & 0 deletions calcite-rs-jni/py_graphql_sql/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""PyTest configuration and fixtures."""
from typing import Any
from unittest.mock import MagicMock
import jaydebeapi
import pytest
from py_graphql_sql import Connection, Cursor, connect

@pytest.fixture
def mock_jdbc_connection() -> MagicMock:
"""Create a mock JDBC connection."""
conn = MagicMock()
conn.cursor.return_value = MagicMock()
return conn

@pytest.fixture
def mock_connection(monkeypatch: pytest.MonkeyPatch, mock_jdbc_connection: MagicMock) -> Connection:
"""Create a mock connection."""
def mock_connect(*args: Any, **kwargs: Any) -> MagicMock:
return mock_jdbc_connection

monkeypatch.setattr(jaydebeapi, 'connect', mock_connect)
return connect('driver', 'url')

@pytest.fixture
def mock_cursor(mock_connection: Connection) -> Cursor:
"""Create a mock cursor."""
return mock_connection.cursor()

0 comments on commit 5c3a350

Please sign in to comment.