test: mock BucketService.find_static in GUI test#465
Conversation
There was a problem hiding this comment.
Pull request overview
This PR mocks the BucketService.find_static method in the test_gui_bucket_shows integration test to prevent test timeouts caused by the slow I/O-bound operation of listing cloud bucket objects.
Changes:
- Patches
Service.find_staticwith an empty list return value in the bucket GUI integration test to avoid slow cloud storage calls during test execution.
Codecov Report✅ All modified and coverable lines are covered by tests. |
|
Claude finished @olivermeyer's task in 2m 40s —— View job PR Review: Mock BucketService.find_static in GUI testSummary✅ APPROVED - This is an excellent fix that correctly addresses a timeout issue in an integration test by mocking an I/O-bound cloud storage operation. The approach is appropriate, follows repository conventions, and demonstrates best practices for integration testing. Todo List
Review Findings✅ Correct Test CategorizationThe test @pytest.mark.integration
async def test_gui_bucket_shows(user: User) -> None:This is appropriate because:
✅ Appropriate Mocking StrategyWhat's being mocked: with patch("aignostics.bucket._gui.Service.find_static", return_value=[]):
await user.open("/bucket")
await user.should_see("The bucket is securely hosted on Google Cloud in EU")Why this is correct:
✅ Follows Repository PatternsThis fix mirrors the pattern in @pytest.mark.integration
async def test_gui_idc_shows(user: User) -> None:
"""Test that the user sees the dataset page."""
await user.open("/dataset/idc")
await user.should_see("Explore Portal")Both tests validate page rendering, not business logic. The bucket test now correctly mocks the slow I/O operation. ✅ Performance Improvement ValidatedBefore fix:
After fix (verified):
✅ Clean Code Quality
Suggestions (Non-Blocking)1. Consider Adding Timeout Override (Optional)While the fix works, you could be extra defensive: @pytest.mark.integration
@pytest.mark.timeout(timeout=20) # Optional: Give extra buffer for NiceGUI teardown
async def test_gui_bucket_shows(user: User) -> None:Rationale: NiceGUI teardown can vary across environments. A 20s timeout is still fast but provides buffer. 2. Document This Pattern (Optional)Consider adding to ### GUI Integration Test Pattern
When testing GUI page rendering that triggers I/O-bound service operations:
1. Mock the service method at the GUI import path
2. Return minimal valid data (empty list for collections)
3. Test only page rendering, not business logic
Example: test_gui_bucket_shows mocks Service.find_static to avoid
cloud storage listing during teardown.Other CI Failures (Unrelated to This PR)The 2 failing tests are NOT caused by this change:
Root cause: The expected file size (160668 bytes ±10%) doesn't match actual (259955 bytes). This is:
Note: There's already a fix merged for this (commit Medical Device Compliance ✅
Final Recommendation✅ APPROVE AND MERGE This PR:
The fix demonstrates excellent understanding of:
Great work! 🎉 |
|



test_gui_bucket_showssometimes exceeds the 10s pytest timeout. Most of that is spent in the teardown phase (observed up to 9s). The hypothesis is thatuser.open("/bucket")calls_get_rows()which runsService.find_staticin a thread; the test immediately succeeds because the test user sees the expected message, but listing the files in the bucket is still running in the background. The teardown lasts until this listing operation ends, which sometimes pushes it over the 10s timeout. I fix this by patching thefind_staticmethod to return an empty list.Observed teardown time before: 8-9s
Observed teardown time after: 2-3s