Skip to content

Add script to generate missing async tests using CST transformations#38

Merged
jason810496 merged 9 commits into
ci/add-ast-based-script-for-async-methodsfrom
copilot/sub-pr-36-again
Jan 6, 2026
Merged

Add script to generate missing async tests using CST transformations#38
jason810496 merged 9 commits into
ci/add-ast-based-script-for-async-methodsfrom
copilot/sub-pr-36-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 5, 2026

Description

Implements compelete_missing_test_for_queue.py script to automatically generate async test versions from sync tests in test_queue.py, following the CST-based pattern established by compelete_missing_async_methods.py.

Changes

  • scripts/compelete_missing_test_for_queue.py: Main script that parses test functions, identifies missing async versions (45 tests), generates them with proper transformations, and formats output

  • scripts/scripts_utils/test_ast.py: CST utilities for test transformations

    • AsyncTestTransformer: Converts pgmq.method()await pgmq.method_async() and time.sleep()await asyncio.sleep()
    • FillMissingTestsToModule: Inserts async tests after sync counterparts and adds asyncio import
  • scripts/scripts_utils/config.py: Added test file path constants

Example transformation

# Input (sync test)
def test_send_and_read_msg(pgmq_setup_teardown):
    pgmq, queue_name = pgmq_setup_teardown
    msg_id = pgmq.send(queue_name, msg)
    time.sleep(1)
    msg_read = pgmq.read(queue_name)

# Output (generated async test)
async def test_send_and_read_msg_async(pgmq_setup_teardown):
    pgmq, queue_name = pgmq_setup_teardown
    msg_id = await pgmq.send_async(queue_name, msg)
    await asyncio.sleep(1)
    msg_read = await pgmq.read_async(queue_name)

Status

  • In progress
  • Ready for review
  • Done

Checklist

  • Read the Contributing Guide
  • Passes tests
  • Linted ( we use pre-commit with ruff )
  • Updated documentation

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

jason810496 and others added 3 commits January 5, 2026 15:53
Distinguish sync and async operations in PGMQueue

- Introduced a pre-commit hook to check for missing async methods in PGMQueue.
- Added scripts to identify and generate missing async methods.
- Created utility functions for AST manipulation and method transformation.
- Established configuration for project paths and console output.
* Initial plan

* Refactor AST-based code to use libcst for better code transformation

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix: only wrap call expressions in await, not literals

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Ask whether to apply change

* Apply missing async methods

* Correct files for check-sync-async-method-for-queue pre-commit

* Add check for operation as well

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>
Copilot AI and others added 3 commits January 5, 2026 12:00
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
…cumentation

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Copilot AI changed the title [WIP] Add missing tests for async methods using CST approach Add script to generate missing async tests using CST transformations Jan 5, 2026
Copilot AI requested a review from jason810496 January 5, 2026 12:06
@jason810496 jason810496 force-pushed the ci/add-ast-based-script-for-async-methods branch from da8aba2 to 9e76606 Compare January 6, 2026 09:25
@jason810496 jason810496 marked this pull request as ready for review January 6, 2026 12:43
@jason810496 jason810496 merged commit 0c0a731 into ci/add-ast-based-script-for-async-methods Jan 6, 2026
jason810496 added a commit that referenced this pull request Jan 6, 2026
* Add pre-commit hooks and scripts for async method checks in PGMQueue

Distinguish sync and async operations in PGMQueue

- Introduced a pre-commit hook to check for missing async methods in PGMQueue.
- Added scripts to identify and generate missing async methods.
- Created utility functions for AST manipulation and method transformation.
- Established configuration for project paths and console output.

* Refactor code transformation scripts from ast to libcst (#35)

* Initial plan

* Refactor AST-based code to use libcst for better code transformation

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix: only wrap call expressions in await, not literals

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Ask whether to apply change

* Apply missing async methods

* Correct files for check-sync-async-method-for-queue pre-commit

* Add check for operation as well

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>

* Add script to generate missing async methods for PGMQOperation (#37)

* Initial plan

* Add compelete_missing_async_methods_for_operation.py script and operation_ast helper

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix path resolution bug in operation_ast.py

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Address code review feedback: improve docstring handling and remove unnecessary method

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Improve docstring handling robustness with better length checks

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix queue await error

* Add script to generate missing async tests for PGMQOperation using CST (#39)

* Add pre-commit hooks and scripts for async method checks in PGMQueue

Distinguish sync and async operations in PGMQueue

- Introduced a pre-commit hook to check for missing async methods in PGMQueue.
- Added scripts to identify and generate missing async methods.
- Created utility functions for AST manipulation and method transformation.
- Established configuration for project paths and console output.

* Refactor code transformation scripts from ast to libcst (#35)

* Initial plan

* Refactor AST-based code to use libcst for better code transformation

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix: only wrap call expressions in await, not literals

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Ask whether to apply change

* Apply missing async methods

* Correct files for check-sync-async-method-for-queue pre-commit

* Add check for operation as well

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>

* Initial plan

* Add compelete_missing_test_for_operation.py script with CST-based approach

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix code review feedback: remove redundant code and use Tuple from typing

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Finalize test_operation

* Fix _check_pg_partman_ext naming

---------

Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Add script to generate missing async tests using CST transformations (#38)

* Add pre-commit hooks and scripts for async method checks in PGMQueue

Distinguish sync and async operations in PGMQueue

- Introduced a pre-commit hook to check for missing async methods in PGMQueue.
- Added scripts to identify and generate missing async methods.
- Created utility functions for AST manipulation and method transformation.
- Established configuration for project paths and console output.

* Refactor code transformation scripts from ast to libcst (#35)

* Initial plan

* Refactor AST-based code to use libcst for better code transformation

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix: only wrap call expressions in await, not literals

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Ask whether to apply change

* Apply missing async methods

* Correct files for check-sync-async-method-for-queue pre-commit

* Add check for operation as well

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>

* Initial plan

* Add complete_missing_test_for_queue.py script with CST-based approach

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Apply ruff formatting to test generation scripts

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Address code review feedback: fix path resolution, type hints, and documentation

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Fix missing async replacment for compelete test queue

* Fix imports for async fixtures

---------

Co-authored-by: LIU ZHE YOU <zhu424.dev@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>

* Unifing script name for queue

* Add missing async test methods for queue, fix check_pg_partman_ext

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants