Repository navigation
Run the cursor_kwargs callbacks in the connection test instead of an S3FS query #1261
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0c90e2a
5e1d56c
cb9e49e
26dbf10
7b04c97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,11 +240,22 @@ def test_cursor_unknown_constructor_keyword(offline_connection, cursor_class): | |
| offline_connection.cursor(cursor_class) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rebase onto fb22d08 after #1258 rewrote this test into an async test over 21 cursor classes, including the aio cursors; the patch series is unchanged, and the conflicts in this test were resolved by keeping master's async structure and adding the Independent follow-up review of the rebase (relayed): Codex CLI 0.163.0, model gpt-6-astra, ChatGPT login, |
||
| "given_by", ["connection", "cursor_kwargs", "cursor_kwargs_over_connection"] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up review 3 (relayed): Codex CLI 0.163.0, model gpt-6-astra, ChatGPT login, P2: the repair put connection callbacks into every Repaired in 911f8b4: the test has three sources,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up review 4 (relayed): Codex CLI 0.163.0, model gpt-6-astra, ChatGPT login, |
||
| ) | ||
| @pytest.mark.parametrize("cursor_class", CURSOR_CLASSES) | ||
| async def test_cursor_accepts_connection_callbacks(offline_connection, cursor_class): | ||
| started, polled = [], [] | ||
| offline_connection.on_start_query_execution = started.append | ||
| offline_connection.on_poll = polled.append | ||
| async def test_cursor_accepts_connection_callbacks(offline_connection, cursor_class, given_by): | ||
| """The connection's callbacks, or the ones its cursor_kwargs give over them, run.""" | ||
| started, polled, overridden = [], [], [] | ||
| callbacks = {"on_start_query_execution": started.append, "on_poll": polled.append} | ||
| if given_by == "connection": | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up review (relayed): Codex CLI 0.163.0, model gpt-6-astra, ChatGPT login, P2: Repaired in 8aeb688: this test runs the callbacks given through the connection's attributes and through its Self-review of |
||
| for name, callback in callbacks.items(): | ||
| setattr(offline_connection, name, callback) | ||
| else: | ||
| if given_by == "cursor_kwargs_over_connection": | ||
| for name in callbacks: | ||
| setattr(offline_connection, name, overridden.append) | ||
| offline_connection.cursor_kwargs = callbacks | ||
|
|
||
| with answered_requests(offline_connection.client): | ||
| async with _opened_cursor(offline_connection, cursor_class) as cursor: | ||
|
|
@@ -260,6 +271,7 @@ async def test_cursor_accepts_connection_callbacks(offline_connection, cursor_cl | |
| assert [execution.state for execution in polled] == ["FAILED"] | ||
| # The Async and Spark cursors do not run on_start_query_execution. | ||
| assert started == (["query-id"] if cursor_class in START_CALLBACK_CURSORS else []) | ||
| assert overridden == [] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up review 2 (relayed): Codex CLI 0.163.0, model gpt-6-astra, ChatGPT login, 1 (P2): the 2 (P2): with one source per case, the connection's callback winning over Self-review of the repair: round 1 CLEAN; round 2: the PR body's description of the test still holds (two sources per class, 28 cases). |
||
|
|
||
|
|
||
| # aio/test_connection.py tests the native asyncio cursors. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review of
ea99b58e17b52252940951210ec445e2f167d9bc..b125bfa4c728f12b31c82ea6c118dedc149758f2.Round 1 (behavior and test quality): CLEAN. The removed test passed the callback through the connection's
cursor_kwargs, whichConnection.cursor()merges into the constructor arguments for every cursor class (pyathena/connection.py:620), andS3FSCursor.execute()calls it atpyathena/s3fs/cursor.py:203. Removing that call failstest_connection.py::test_cursor_accepts_connection_callbacks[S3FSCursor]offline.contextlib,connect, andENVstay in use by the remaining tests;just lintpassed.Round 2 (claims and operation): CLEAN. On ea99b58,
START_CALLBACK_CURSORSincludesS3FSCursor(tests/pyathena/test_connection.py:55), the cover asserts the started query ID and the polled state, andTestS3FSCursor::test_on_start_query_execution_executekeeps theexecute()callback. The change saves one Athena query per run; no local live run, as the PR body states.