Skip to content

πŸ›‘οΈ Shield: ImednetSDK Client Cleanup Context Manager Test Defenses#746

Merged
fderuiter merged 2 commits intomainfrom
shield-context-manager-coverage-15198065894649759431
Mar 30, 2026
Merged

πŸ›‘οΈ Shield: ImednetSDK Client Cleanup Context Manager Test Defenses#746
fderuiter merged 2 commits intomainfrom
shield-context-manager-coverage-15198065894649759431

Conversation

@fderuiter
Copy link
Copy Markdown
Owner

Implements complete test defenses covering missing loop verification contexts, and context managers around ImednetSDK. Closes gaps where properties (RetryPolicy) and AsyncClient and Client mock execution loops where not asserted or left in unresolved warning states in automated tests.

Adds deterministic tests to test deprecation warnings and all SDK exit paths correctly. Increases coverage of src/imednet/sdk.py to 100%.


PR created automatically by Jules for task 15198065894649759431 started by @fderuiter

πŸ›‘ Vulnerability: The `ImednetSDK.close()` function contained untested paths for handling loop retrieval. Specifically, if a RuntimeError was raised when `asyncio.get_running_loop()` was called, the loop was closed, or it had an active event loop that was not closed. Missing tests and tests being skipped caused missing test coverage over the core cleanup flows. Additionally `AsyncImednetSDK` deprecation warnings were left untested creating test suites with warnings.

πŸ›‘οΈ Defense: Implemented complete testing for `ImednetSDK` context managers in `test_sdk_context.py` and `AsyncImednetSDK` tests in `test_async_sdk_deprecation.py`. Evaluated event loops rigorously using `unittest.mock.patch` for loops and mocked unawaited states to correctly ensure `Client.close()` and `AsyncClient.aclose()` were verified without error paths dropping logic checks.

πŸ”¬ Verification: Run `poetry run pytest tests/unit/test_sdk_context.py tests/unit/test_async_sdk_deprecation.py --cov=src/imednet/sdk.py`.

πŸ“Š Impact: Improved test coverage of `src/imednet/sdk.py` to 100%. Ensures clients are confidently closed using deterministic mocking without leaving dangling loop connections.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

πŸ›‘ Vulnerability: The test files introduced (`tests/unit/test_sdk_context.py` and `tests/unit/test_async_sdk_deprecation.py`) were missing `black`, `isort`, and `ruff` formatting, causing the 'Quality & Security' CI to fail on PR creation.

πŸ›‘οΈ Defense: Run `black`, `isort` and `ruff` linters on all new test suites fixing imports, spacing, and long string values in the test functions.

πŸ”¬ Verification: Run `poetry run black --check .` and ensure all tests are formatted.

πŸ“Š Impact: Allows CI builds to pass validation.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@fderuiter fderuiter marked this pull request as ready for review March 30, 2026 14:49
@fderuiter fderuiter merged commit 958b8f0 into main Mar 30, 2026
13 checks passed
@fderuiter fderuiter deleted the shield-context-manager-coverage-15198065894649759431 branch April 22, 2026 19:39
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.

1 participant