aminghadersohi commented on code in PR #38576:
URL: https://github.com/apache/superset/pull/38576#discussion_r3477278406


##########
tests/unit_tests/utils/test_screenshot_cache_fix.py:
##########
@@ -149,38 +153,34 @@ def test_cache_saved_only_when_image_generated(
         assert cached_value["status"] == "Updated"
         assert cached_value["image"] is not None
 
-    def test_no_intermediate_cache_during_computing(
+    def test_computing_status_written_to_cache_early(
         self, mocker: MockerFixture, screenshot_obj, mock_user
     ):

Review Comment:
   Fixed in commit edf739e — added type annotations to fixtures, helpers, and 
test functions matching the project convention.



##########
tests/unit_tests/utils/test_screenshot_cache_fix.py:
##########
@@ -408,3 +414,33 @@ def test_stale_computing_triggers_retry(
         assert cached_value is not None
         assert cached_value["status"] == "Updated"
         assert cached_value["image"] is not None
+
+    def test_concurrent_task_skips_when_lock_already_held(
+        self, mocker: MockerFixture, screenshot_obj, mock_user
+    ):

Review Comment:
   Fixed in commit edf739e — added type annotations to fixtures, helpers, and 
test functions matching the project convention.



##########
tests/unit_tests/utils/test_screenshot_cache_fix.py:
##########
@@ -408,3 +414,33 @@ def test_stale_computing_triggers_retry(
         assert cached_value is not None
         assert cached_value["status"] == "Updated"
         assert cached_value["image"] is not None
+
+    def test_concurrent_task_skips_when_lock_already_held(
+        self, mocker: MockerFixture, screenshot_obj, mock_user
+    ):
+        """compute_and_cache exits without rendering when the distributed lock
+        is already held by another worker — atomically preventing duplicate 
Selenium."""
+        mock_lock = mocker.patch(DISTRIBUTED_LOCK_PATH)
+        mock_lock.return_value.__enter__.side_effect = (
+            AcquireDistributedLockFailedException("lock held")
+        )
+        get_screenshot = mocker.patch(BASE_SCREENSHOT_PATH + ".get_screenshot")
+        BaseScreenshot.cache = MockCache()
+
+        screenshot_obj.compute_and_cache(user=mock_user, force=False)
+
+        get_screenshot.assert_not_called()
+
+    def test_computing_preserves_previous_image(
+        self, mocker: MockerFixture, screenshot_obj, mock_user
+    ):

Review Comment:
   Fixed in commit edf739e — added type annotations to fixtures, helpers, and 
test functions matching the project convention.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to