-
Notifications
You must be signed in to change notification settings - Fork 0
Fix test coverage gaps: unused imports, mock unix socket init, and cleanup #6
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
Conversation
Co-authored-by: ochui <[email protected]>
Co-authored-by: ochui <[email protected]>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
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.
Pull request overview
This PR tightens test quality around Redis initialization and cleanup, removing an unused mock import, making the Unix-socket initialization test exercise the real code path, and adding Redis cleanup logic for edge-case tests.
Changes:
- Removed an unused
patchimport fromtests/test_func.pyand addedMagicMockfor more flexible mocking. - Reworked
test_initialize_unix_socket_connectionto patchfq.queue.Redis, callFQ._initialize(), and assert that the Unix socket path and DB index are passed correctly. - Added
asyncTearDownandfq_instancetracking intests/test_edge_cases.pyto perform Redis DB flush and connection cleanup around tests that use a real Redis client.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_func.py | Cleans up mock imports and strengthens the Unix-socket Redis initialization test by exercising the actual _initialize path and verifying constructor kwargs. |
| tests/test_edge_cases.py | Introduces per-test Redis cleanup via asyncTearDown and tracks real FQ instances to avoid cross-test interference and resource warnings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # If a test initialized FQ with real Redis, clean up | ||
| if self.fq_instance is not None: | ||
| try: | ||
| if self.fq_instance._r is not None: | ||
| await self.fq_instance._r.flushdb() |
Copilot
AI
Jan 26, 2026
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.
The new asyncTearDown is intended to flush Redis and close connections after each test, but the current pattern of setting self.fq_instance = None inside tests (e.g., lines 176-185, 189-196, 270-276) means that on successful test runs this teardown block is skipped, so Redis state is not actually cleaned between tests. To ensure the cleanup described in the PR, consider relying on asyncTearDown as the single place that closes and resets fq_instance (and avoid resetting it to None in the tests themselves), or at least avoid clearing self.fq_instance before teardown runs.
tests/test_func.py
Outdated
| # Verify that Redis was initialized with unix_socket_path | ||
| self.assertIn('unix_socket_path', redis_init_kwargs) | ||
| self.assertEqual(redis_init_kwargs['unix_socket_path'], '/tmp/redis_nonexistent.sock') | ||
| self.assertEqual(redis_init_kwargs['db'], '0') |
Copilot
AI
Jan 26, 2026
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.
This assertion tightly couples the test to db being the string '0', even though the production code only requires that the logical DB index be 0. To make the test less brittle against harmless implementation changes (e.g., casting db to an int), consider asserting on the numeric value instead, or relaxing the check so it does not depend on the exact type representation.
| self.assertEqual(redis_init_kwargs['db'], '0') | |
| self.assertEqual(int(redis_init_kwargs['db']), 0) |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: ochui <[email protected]>
I've applied both changes from the review in commit a5c0934:
All tests pass including the full edge case test suite (12/12 tests). |
patchimport from tests/test_func.py💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.