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


##########
tests/unit_tests/tasks/test_thumbnails.py:
##########
@@ -0,0 +1,143 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from collections.abc import Callable, Iterator
+from typing import Any
+from unittest.mock import ANY, MagicMock, patch
+
+import pytest
+
+
[email protected]
+def mock_thumbnail_cache() -> Iterator[None]:
+    with patch("superset.tasks.thumbnails.thumbnail_cache", True):
+        yield

Review Comment:
   Fixed in 17c615f — added docstring to mock_thumbnail_cache fixture.



##########
tests/unit_tests/utils/test_screenshot_cache_fix.py:
##########
@@ -149,38 +153,37 @@ 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(
-        self, mocker: MockerFixture, screenshot_obj, mock_user
-    ):
-        """Test that cache is not saved during COMPUTING state."""
+    def test_computing_status_written_to_cache_early(
+        self,
+        mocker: MockerFixture,
+        screenshot_obj: BaseScreenshot,
+        mock_user: MagicMock,
+    ) -> None:
+        """compute_and_cache writes COMPUTING to cache before taking the 
screenshot
+        so concurrent tasks can detect it and avoid duplicate work."""
+        mocker.patch(DISTRIBUTED_LOCK_PATH)
         mocker.patch(BASE_SCREENSHOT_PATH + ".get_from_cache_key", 
return_value=None)
         BaseScreenshot.cache = MockCache()
 
-        # Mock get_screenshot to check cache state during execution
         def check_cache_during_screenshot(*args, **kwargs):

Review Comment:
   Fixed in 17c615f — added *args: object, **kwargs: object and -> bytes 
annotations to check_cache_during_screenshot.



##########
tests/unit_tests/tasks/test_thumbnails.py:
##########
@@ -0,0 +1,143 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from collections.abc import Callable, Iterator
+from typing import Any
+from unittest.mock import ANY, MagicMock, patch
+
+import pytest
+
+
[email protected]
+def mock_thumbnail_cache() -> Iterator[None]:
+    with patch("superset.tasks.thumbnails.thumbnail_cache", True):
+        yield
+
+
[email protected]
+def mock_dashboard() -> MagicMock:
+    dashboard = MagicMock()
+    dashboard.id = 1
+    dashboard.digest = "test_digest"
+    return dashboard

Review Comment:
   Fixed in 17c615f — added docstring to mock_dashboard fixture.



-- 
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