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

SNOW-1882588 Add Test for PR 2136 #2138

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions test/unit/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ def test_cursor_attribute():
assert cursor.lastrowid is None


def test_query_can_be_empty_with_dataframe_ast():
def mock_is_closed(*args, **kwargs):
return False

fake_conn = FakeConnection()
fake_conn.is_closed = mock_is_closed
cursor = SnowflakeCursor(fake_conn)
# when `dataframe_ast` is not presented, the execute function return None
assert cursor.execute("") is None
# when `dataframe_ast` is presented, it should not return `None`
# but raise `AttributeError` since `_paramstyle` is not set in FakeConnection.
with pytest.raises(AttributeError):
cursor.execute("", _dataframe_ast="ABCD")


@patch("snowflake.connector.cursor.SnowflakeCursor._SnowflakeCursor__cancel_query")
def test_cursor_execute_timeout(mockCancelQuery):
def mock_cmd_query(*args, **kwargs):
Expand Down
Loading